(function (az, aW, al) {
	var ay = {
		transition : "elastic",
		speed : 300,
		width : false,
		initialWidth : "600",
		innerWidth : false,
		maxWidth : false,
		height : false,
		initialHeight : "450",
		innerHeight : false,
		maxHeight : false,
		scalePhotos : true,
		scrolling : true,
		inline : false,
		html : false,
		iframe : false,
		fastIframe : true,
		photo : false,
		href : false,
		title : false,
		rel : false,
		opacity : 0.9,
		preloading : true,
		current : "image {current} of {total}",
		previous : "previous",
		next : "next",
		close : "close",
		open : false,
		returnFocus : true,
		loop : true,
		slideshow : false,
		slideshowAuto : true,
		slideshowSpeed : 2500,
		slideshowStart : "start slideshow",
		slideshowStop : "stop slideshow",
		onOpen : false,
		onLoad : false,
		onComplete : false,
		onCleanup : false,
		onClosed : false,
		overlayClose : true,
		escKey : true,
		arrowKey : true
	},
	aL = "colorbox",
	ao = "cbox",
	am = ao + "_open",
	a2 = ao + "_load",
	an = ao + "_complete",
	aO = ao + "_cleanup",
	ag = ao + "_closed",
	aY = ao + "_purge",
	aN = az.browser.msie && !az.support.opacity,
	ad = aN && az.browser.version < 7,
	ah = ao + "_IE6",
	aq,
	aG,
	aF,
	a3,
	aB,
	aS,
	a5,
	ar,
	a4,
	ai,
	av,
	aX,
	aZ,
	aT,
	aP,
	ak,
	aQ,
	ap,
	aJ,
	aI,
	af = {},
	aD,
	aV,
	a0,
	a6,
	aM,
	aA,
	aU,
	aE,
	aj,
	aw = false,
	ax,
	aR = ao + "Element";
	function at(a, c) {
		var b = aW.createElement("div");
		if (a) {
			b.id = ao + a
		}
		b.style.cssText = c || false;
		return az(b)
	}
	function au(b, a) {
		a = a === "x" ? ai.width() : ai.height();
		return (typeof b === "string") ? Math.round((/%/.test(b) ? (a / 100) * parseInt(b, 10) : parseInt(b, 10))) : b
	}
	function aH(a) {
		return af.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)
	}
	function ae(b) {
		for (var c in b) {
			if (az.isFunction(b[c]) && c.substring(0, 2) !== "on") {
				b[c] = b[c].call(aM)
			}
		}
		var a = az(aM);
		b.iframe = b.iframe || a.attr("ColorBoxIframe") == "true";
		b.width = b.width || a.attr("ColorBoxWidth");
		b.height = b.height || a.attr("ColorBoxHeight");
		b.rel = b.rel || aM.rel || "nofollow";
		b.href = az.trim(b.href || az(aM).attr("href"));
		b.title = b.title || aM.title
	}
	function aC(b, a) {
		if (a) {
			a.call(aM)
		}
		az.event.trigger(b)
	}
	function aK() {
		var e,
		c = ao + "Slideshow_",
		b = "click." + ao,
		a,
		d,
		f;
		if (af.slideshow && a4[1]) {
			a = function () {
				ak.text(af.slideshowStop).unbind(b).bind(an, function () {
					if (aA < a4.length - 1 || af.loop) {
						e = setTimeout(ax.next, af.slideshowSpeed)
					}
				}).bind(a2, function () {
					clearTimeout(e)
				}).one(b + " " + aO, d);
				aG.removeClass(c + "off").addClass(c + "on");
				e = setTimeout(ax.next, af.slideshowSpeed)
			};
			d = function () {
				clearTimeout(e);
				ak.text(af.slideshowStart).unbind([an, a2, aO, b].join(" ")).one(b, a);
				aG.removeClass(c + "on").addClass(c + "off")
			};
			if (af.slideshowAuto) {
				a()
			} else {
				d()
			}
		}
	}
	function a1(b) {
		if (!aw) {
			aM = b;
			ae(az.extend(af, az.data(aM, aL)));
			a4 = az(aM);
			aA = 0;
			if (af.rel !== "nofollow") {
				a4 = az("." + aR).filter(function () {
						var c = az.data(this, aL).rel || this.rel;
						return (c === af.rel)
					});
				aA = a4.index(aM);
				if (aA === -1) {
					a4 = a4.add(aM);
					aA = a4.length - 1
				}
			}
			if (!aE) {
				aE = aj = true;
				aG.show();
				if (af.returnFocus) {
					try {
						aM.blur();
						az(aM).one(ag, function () {
							try {
								this.focus()
							} catch (c) {}

						})
					} catch (a) {}

				}
				aq.css({
					opacity : +af.opacity,
					cursor : af.overlayClose ? "pointer" : "auto"
				}).show();
				af.w = au(af.initialWidth, "x");
				af.h = au(af.initialHeight, "y");
				ax.position(0);
				if (ad) {
					ai.bind("resize." + ah + " scroll." + ah, function () {
						aq.css({
							width : ai.width(),
							height : ai.height(),
							top : ai.scrollTop(),
							left : ai.scrollLeft()
						})
					}).trigger("resize." + ah)
				}
				aC(am, af.onOpen);
				aI.add(aT).hide();
				aJ.html(af.close).show()
			}
			ax.load(true)
		}
	}
	ax = az.fn[aL] = az[aL] = function (d, a) {
		var c = this,
		b;
		if (!c[0] && c.selector) {
			return c
		}
		d = d || {};
		if (a) {
			d.onComplete = a
		}
		if (!c[0] || c.selector === undefined) {
			c = az("<a/>");
			d.open = true
		}
		c.each(function () {
			az.data(this, aL, az.extend({}, az.data(this, aL) || ay, d));
			az(this).addClass(aR)
		});
		b = d.open;
		if (az.isFunction(b)) {
			b = b.call(c)
		}
		if (b) {
			a1(c[0])
		}
		return c
	};
	ax.init = function () {
		ai = az(al);
		aG = at().attr({
				id : aL,
				"class" : aN ? ao + (ad ? "IE6" : "IE") : ""
			});
		aq = at("Overlay", ad ? "position:absolute" : "").hide();
		aF = at("Wrapper");
		a3 = at("Content").append(av = at("LoadedContent", "width:0; height:0; overflow:hidden"), aZ = at("LoadingOverlay").add(at("LoadingGraphic")), aT = at("Title"), aP = at("Current"), aQ = at("Next"), ap = at("Previous"), ak = at("Slideshow").bind(am, aK), aJ = at("Close"));
		aF.append(at().append(at("TopLeft"), aB = at("TopCenter"), at("TopRight")), at(false, "clear:left").append(aS = at("MiddleLeft"), a3, a5 = at("MiddleRight")), at(false, "clear:left").append(at("BottomLeft"), ar = at("BottomCenter"), at("BottomRight"))).children().children().css({
			"float" : "left"
		});
		aX = at(false, "position:absolute; width:9999px; visibility:hidden; display:none");
		az("body").prepend(aq, aG.append(aF, aX));
		a3.children().hover(function () {
			az(this).addClass("hover")
		}, function () {
			az(this).removeClass("hover")
		}).addClass("hover");
		aD = aB.height() + ar.height() + a3.outerHeight(true) - a3.height();
		aV = aS.width() + a5.width() + a3.outerWidth(true) - a3.width();
		a0 = av.outerHeight(true);
		a6 = av.outerWidth(true);
		aG.css({
			"padding-bottom" : aD,
			"padding-right" : aV
		}).hide();
		aQ.click(function () {
			ax.next()
		});
		ap.click(function () {
			ax.prev()
		});
		aJ.click(function () {
			ax.close()
		});
		aI = aQ.add(ap).add(aP).add(ak);
		a3.children().removeClass("hover");
		az("." + aR).live("click", function (a) {
			if (!((a.button !== 0 && typeof a.button !== "undefined") || a.ctrlKey || a.shiftKey || a.altKey)) {
				a.preventDefault();
				a1(this)
			}
		});
		aq.click(function () {
			if (af.overlayClose) {
				ax.close()
			}
		});
		az(aW).bind("keydown." + ao, function (a) {
			var b = a.keyCode;
			if (aE && af.escKey && b === 27) {
				a.preventDefault();
				ax.close()
			}
			if (aE && af.arrowKey && a4[1]) {
				if (b === 37) {
					a.preventDefault();
					ap.click()
				} else {
					if (b === 39) {
						a.preventDefault();
						aQ.click()
					}
				}
			}
		})
	};
	ax.remove = function () {
		aG.add(aq).remove();
		az("." + aR).die("click").removeData(aL).removeClass(aR)
	};
	ax.position = function (b, e) {
		var c,
		d = Math.max(aW.documentElement.clientHeight - af.h - a0 - aD, 0) / 2 + ai.scrollTop(),
		f = Math.max(ai.width() - af.w - a6 - aV, 0) / 2 + ai.scrollLeft();
		c = (aG.width() === af.w + a6 && aG.height() === af.h + a0) ? 0 : b;
		aF[0].style.width = aF[0].style.height = "9999px";
		function a(g) {
			aB[0].style.width = ar[0].style.width = a3[0].style.width = g.style.width;
			aZ[0].style.height = aZ[1].style.height = a3[0].style.height = aS[0].style.height = a5[0].style.height = g.style.height
		}
		aG.dequeue().animate({
			width : af.w + a6,
			height : af.h + a0,
			top : d,
			left : f
		}, {
			duration : c,
			complete : function () {
				a(this);
				aj = false;
				aF[0].style.width = (af.w + a6 + aV) + "px";
				aF[0].style.height = (af.h + a0 + aD) + "px";
				if (e) {
					e()
				}
			},
			step : function () {
				a(this)
			}
		})
	};
	ax.resize = function (b) {
		if (aE) {
			b = b || {};
			if (b.width) {
				af.w = au(b.width, "x") - a6 - aV
			}
			if (b.innerWidth) {
				af.w = au(b.innerWidth, "x")
			}
			av.css({
				width : af.w
			});
			if (b.height) {
				af.h = au(b.height, "y") - a0 - aD
			}
			if (b.innerHeight) {
				af.h = au(b.innerHeight, "y")
			}
			if (!b.innerHeight && !b.height) {
				var a = av.wrapInner("<div style='overflow:auto'></div>").children();
				af.h = a.height();
				a.replaceWith(a.children())
			}
			av.css({
				height : af.h
			});
			ax.position(af.transition === "none" ? 0 : af.speed)
		}
	};
	ax.prep = function (c) {
		if (!aE) {
			return
		}
		var b = af.transition === "none" ? 0 : af.speed;
		ai.unbind("resize." + ao);
		av.remove();
		av = at("LoadedContent").html(c);
		function e() {
			af.w = af.w || av.width();
			af.w = af.mw && af.mw < af.w ? af.mw : af.w;
			return af.w
		}
		function a() {
			af.h = af.h || av.height();
			af.h = af.mh && af.mh < af.h ? af.mh : af.h;
			return af.h
		}
		av.hide().appendTo(aX.show()).css({
			width : e(),
			overflow : af.scrolling ? "auto" : "hidden"
		}).css({
			height : a()
		}).prependTo(a3);
		aX.hide();
		az(aU).css({
			"float" : "none"
		});
		if (ad) {
			az("select").not(aG.find("select")).filter(function () {
				return this.style.visibility !== "hidden"
			}).css({
				visibility : "hidden"
			}).one(aO, function () {
				this.style.visibility = "inherit"
			})
		}
		function d(f) {
			ax.position(f, function () {
				var h,
				g,
				j,
				k,
				i = a4.length,
				l,
				m;
				if (!aE) {
					return
				}
				m = function () {
					aZ.hide();
					aC(an, af.onComplete)
				};
				if (aN) {
					if (aU) {
						av.fadeIn(100)
					}
				}
				aT.html(af.title).add(av).show();
				if (i > 1) {
					if (typeof af.current === "string") {
						aP.html(af.current.replace(/\{current\}/, aA + 1).replace(/\{total\}/, i)).show()
					}
					aQ[(af.loop || aA < i - 1) ? "show" : "hide"]().html(af.next);
					ap[(af.loop || aA) ? "show" : "hide"]().html(af.previous);
					h = aA ? a4[aA - 1] : a4[i - 1];
					j = aA < i - 1 ? a4[aA + 1] : a4[0];
					if (af.slideshow) {
						ak.show()
					}
					if (af.preloading) {
						k = az.data(j, aL).href || j.href;
						g = az.data(h, aL).href || h.href;
						k = az.isFunction(k) ? k.call(j) : k;
						g = az.isFunction(g) ? g.call(h) : g;
						if (aH(k)) {
							az("<img/>")[0].src = k
						}
						if (aH(g)) {
							az("<img/>")[0].src = g
						}
					}
				} else {
					aI.hide()
				}
				if (af.iframe) {
					l = az("<iframe/>").addClass(ao + "Iframe")[0];
					if (af.fastIframe) {
						m()
					} else {
						az(l).load(m)
					}
					l.name = ao + (+new Date());
					l.src = af.href;
					if (!af.scrolling) {
						l.scrolling = "no"
					}
					if (aN) {
						l.frameBorder = 0;
						l.allowTransparency = "true"
					}
					az(l).appendTo(av).one(aY, function () {
						l.src = "//about:blank"
					})
				} else {
					m()
				}
				if (af.transition === "fade") {
					aG.fadeTo(b, 1, function () {
						aG[0].style.filter = ""
					})
				} else {
					aG[0].style.filter = ""
				}
				ai.bind("resize." + ao, function () {
					ax.position(0)
				})
			})
		}
		if (af.transition === "fade") {
			aG.fadeTo(b, 0, function () {
				d(0)
			})
		} else {
			d(b)
		}
	};
	ax.load = function (b) {
		var c,
		a,
		d = ax.prep;
		aj = true;
		aU = false;
		aM = a4[aA];
		if (!b) {
			ae(az.extend(af, az.data(aM, aL)))
		}
		aC(aY);
		aC(a2, af.onLoad);
		af.h = af.height ? au(af.height, "y") - a0 - aD : af.innerHeight && au(af.innerHeight, "y");
		af.w = af.width ? au(af.width, "x") - a6 - aV : af.innerWidth && au(af.innerWidth, "x");
		af.mw = af.w;
		af.mh = af.h;
		if (af.maxWidth) {
			af.mw = au(af.maxWidth, "x") - a6 - aV;
			af.mw = af.w && af.w < af.mw ? af.w : af.mw
		}
		if (af.maxHeight) {
			af.mh = au(af.maxHeight, "y") - a0 - aD;
			af.mh = af.h && af.h < af.mh ? af.h : af.mh
		}
		c = af.href;
		aZ.show();
		if (af.inline) {
			at().hide().insertBefore(az(c)[0]).one(aY, function () {
				az(this).replaceWith(av.children())
			});
			d(az(c))
		} else {
			if (af.iframe) {
				d(" ")
			} else {
				if (af.html) {
					d(af.html)
				} else {
					if (aH(c)) {
						az(aU = new Image()).addClass(ao + "Photo").error(function () {
							af.title = false;
							d(at("Error").text("This image could not be loaded"))
						}).load(function () {
							var e;
							aU.onload = null;
							if (af.scalePhotos) {
								a = function () {
									aU.height -= aU.height * e;
									aU.width -= aU.width * e
								};
								if (af.mw && aU.width > af.mw) {
									e = (aU.width - af.mw) / aU.width;
									a()
								}
								if (af.mh && aU.height > af.mh) {
									e = (aU.height - af.mh) / aU.height;
									a()
								}
							}
							if (af.h) {
								aU.style.marginTop = Math.max(af.h - aU.height, 0) / 2 + "px"
							}
							if (a4[1] && (aA < a4.length - 1 || af.loop)) {
								aU.style.cursor = "pointer";
								aU.onclick = function () {
									ax.next()
								}
							}
							if (aN) {
								aU.style.msInterpolationMode = "bicubic"
							}
							setTimeout(function () {
								d(aU)
							}, 1)
						});
						setTimeout(function () {
							aU.src = c
						}, 1)
					} else {
						if (c) {
							aX.load(c, function (e, f, g) {
								d(f === "error" ? at("Error").text("Request unsuccessful: " + g.statusText) : az(this).contents())
							})
						}
					}
				}
			}
		}
	};
	ax.next = function () {
		if (!aj && a4[1] && (aA < a4.length - 1 || af.loop)) {
			aA = aA < a4.length - 1 ? aA + 1 : 0;
			ax.load()
		}
	};
	ax.prev = function () {
		if (!aj && a4[1] && (aA || af.loop)) {
			aA = aA ? aA - 1 : a4.length - 1;
			ax.load()
		}
	};
	ax.close = function () {
		if (aE && !aw) {
			aw = true;
			aE = false;
			aC(aO, af.onCleanup);
			ai.unbind("." + ao + " ." + ah);
			aq.fadeTo(200, 0);
			aG.stop().fadeTo(300, 0, function () {
				aG.add(aq).css({
					opacity : 1,
					cursor : "auto"
				}).hide();
				aC(aY);
				av.remove();
				setTimeout(function () {
					aw = false;
					aC(ag, af.onClosed)
				}, 1)
			})
		}
	};
	ax.element = function () {
		return az(aM)
	};
	ax.settings = ay;
	az(ax.init)
}
	(jQuery, document, this));
var Base64 = (function () {
	var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var b = {
		encode : function (e) {
			var c = "";
			var m,
			k,
			h;
			var l,
			j,
			g,
			f;
			var d = 0;
			do {
				m = e.charCodeAt(d++);
				k = e.charCodeAt(d++);
				h = e.charCodeAt(d++);
				l = m >> 2;
				j = ((m & 3) << 4) | (k >> 4);
				g = ((k & 15) << 2) | (h >> 6);
				f = h & 63;
				if (isNaN(k)) {
					g = f = 64
				} else {
					if (isNaN(h)) {
						f = 64
					}
				}
				c = c + a.charAt(l) + a.charAt(j) + a.charAt(g) + a.charAt(f)
			} while (d < e.length);
			return c
		},
		decode : function (e) {
			var c = "";
			var m,
			k,
			h;
			var l,
			j,
			g,
			f;
			var d = 0;
			e = e.replace(/[^A-Za-z0-9\+\/\=]/g, "");
			do {
				l = a.indexOf(e.charAt(d++));
				j = a.indexOf(e.charAt(d++));
				g = a.indexOf(e.charAt(d++));
				f = a.indexOf(e.charAt(d++));
				m = (l << 2) | (j >> 4);
				k = ((j & 15) << 4) | (g >> 2);
				h = ((g & 3) << 6) | f;
				c = c + String.fromCharCode(m);
				if (g != 64) {
					c = c + String.fromCharCode(k)
				}
				if (f != 64) {
					c = c + String.fromCharCode(h)
				}
			} while (d < e.length);
			return c
		}
	};
	return b
})();
var MD5 = (function () {
	var o = 0;
	var a = "";
	var l = 8;
	var j = function (r, u) {
		var t = (r & 65535) + (u & 65535);
		var s = (r >> 16) + (u >> 16) + (t >> 16);
		return (s << 16) | (t & 65535)
	};
	var n = function (r, s) {
		return (r << s) | (r >>> (32 - s))
	};
	var b = function (u) {
		var t = [];
		var r = (1 << l) - 1;
		for (var s = 0; s < u.length * l; s += l) {
			t[s >> 5] |= (u.charCodeAt(s / l) & r) << (s % 32)
		}
		return t
	};
	var g = function (t) {
		var u = "";
		var r = (1 << l) - 1;
		for (var s = 0; s < t.length * 32; s += l) {
			u += String.fromCharCode((t[s >> 5] >>> (s % 32)) & r)
		}
		return u
	};
	var q = function (t) {
		var s = o ? "0123456789ABCDEF" : "0123456789abcdef";
		var u = "";
		for (var r = 0; r < t.length * 4; r++) {
			u += s.charAt((t[r >> 2] >> ((r % 4) * 8 + 4)) & 15) + s.charAt((t[r >> 2] >> ((r % 4) * 8)) & 15)
		}
		return u
	};
	var p = function (u) {
		var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
		var w = "";
		var v,
		r;
		for (var s = 0; s < u.length * 4; s += 3) {
			v = (((u[s >> 2] >> 8 * (s % 4)) & 255) << 16) | (((u[s + 1 >> 2] >> 8 * ((s + 1) % 4)) & 255) << 8) | ((u[s + 2 >> 2] >> 8 * ((s + 2) % 4)) & 255);
			for (r = 0; r < 4; r++) {
				if (s * 8 + r * 6 > u.length * 32) {
					w += a
				} else {
					w += t.charAt((v >> 6 * (3 - r)) & 63)
				}
			}
		}
		return w
	};
	var d = function (z, v, u, r, y, w) {
		return j(n(j(j(v, z), j(r, w)), y), u)
	};
	var k = function (v, u, A, z, r, y, w) {
		return d((u & A) | ((~u) & z), v, u, r, y, w)
	};
	var c = function (v, u, A, z, r, y, w) {
		return d((u & z) | (A & (~z)), v, u, r, y, w)
	};
	var m = function (v, u, A, z, r, y, w) {
		return d(u^A^z, v, u, r, y, w)
	};
	var i = function (v, u, A, z, r, y, w) {
		return d(A^(u | (~z)), v, u, r, y, w)
	};
	var f = function (C, w) {
		C[w >> 5] |= 128 << ((w) % 32);
		C[(((w + 64) >>> 9) << 4) + 14] = w;
		var B = 1732584193;
		var A = -271733879;
		var z = -1732584194;
		var y = 271733878;
		var v,
		u,
		t,
		r;
		for (var s = 0; s < C.length; s += 16) {
			v = B;
			u = A;
			t = z;
			r = y;
			B = k(B, A, z, y, C[s + 0], 7, -680876936);
			y = k(y, B, A, z, C[s + 1], 12, -389564586);
			z = k(z, y, B, A, C[s + 2], 17, 606105819);
			A = k(A, z, y, B, C[s + 3], 22, -1044525330);
			B = k(B, A, z, y, C[s + 4], 7, -176418897);
			y = k(y, B, A, z, C[s + 5], 12, 1200080426);
			z = k(z, y, B, A, C[s + 6], 17, -1473231341);
			A = k(A, z, y, B, C[s + 7], 22, -45705983);
			B = k(B, A, z, y, C[s + 8], 7, 1770035416);
			y = k(y, B, A, z, C[s + 9], 12, -1958414417);
			z = k(z, y, B, A, C[s + 10], 17, -42063);
			A = k(A, z, y, B, C[s + 11], 22, -1990404162);
			B = k(B, A, z, y, C[s + 12], 7, 1804603682);
			y = k(y, B, A, z, C[s + 13], 12, -40341101);
			z = k(z, y, B, A, C[s + 14], 17, -1502002290);
			A = k(A, z, y, B, C[s + 15], 22, 1236535329);
			B = c(B, A, z, y, C[s + 1], 5, -165796510);
			y = c(y, B, A, z, C[s + 6], 9, -1069501632);
			z = c(z, y, B, A, C[s + 11], 14, 643717713);
			A = c(A, z, y, B, C[s + 0], 20, -373897302);
			B = c(B, A, z, y, C[s + 5], 5, -701558691);
			y = c(y, B, A, z, C[s + 10], 9, 38016083);
			z = c(z, y, B, A, C[s + 15], 14, -660478335);
			A = c(A, z, y, B, C[s + 4], 20, -405537848);
			B = c(B, A, z, y, C[s + 9], 5, 568446438);
			y = c(y, B, A, z, C[s + 14], 9, -1019803690);
			z = c(z, y, B, A, C[s + 3], 14, -187363961);
			A = c(A, z, y, B, C[s + 8], 20, 1163531501);
			B = c(B, A, z, y, C[s + 13], 5, -1444681467);
			y = c(y, B, A, z, C[s + 2], 9, -51403784);
			z = c(z, y, B, A, C[s + 7], 14, 1735328473);
			A = c(A, z, y, B, C[s + 12], 20, -1926607734);
			B = m(B, A, z, y, C[s + 5], 4, -378558);
			y = m(y, B, A, z, C[s + 8], 11, -2022574463);
			z = m(z, y, B, A, C[s + 11], 16, 1839030562);
			A = m(A, z, y, B, C[s + 14], 23, -35309556);
			B = m(B, A, z, y, C[s + 1], 4, -1530992060);
			y = m(y, B, A, z, C[s + 4], 11, 1272893353);
			z = m(z, y, B, A, C[s + 7], 16, -155497632);
			A = m(A, z, y, B, C[s + 10], 23, -1094730640);
			B = m(B, A, z, y, C[s + 13], 4, 681279174);
			y = m(y, B, A, z, C[s + 0], 11, -358537222);
			z = m(z, y, B, A, C[s + 3], 16, -722521979);
			A = m(A, z, y, B, C[s + 6], 23, 76029189);
			B = m(B, A, z, y, C[s + 9], 4, -640364487);
			y = m(y, B, A, z, C[s + 12], 11, -421815835);
			z = m(z, y, B, A, C[s + 15], 16, 530742520);
			A = m(A, z, y, B, C[s + 2], 23, -995338651);
			B = i(B, A, z, y, C[s + 0], 6, -198630844);
			y = i(y, B, A, z, C[s + 7], 10, 1126891415);
			z = i(z, y, B, A, C[s + 14], 15, -1416354905);
			A = i(A, z, y, B, C[s + 5], 21, -57434055);
			B = i(B, A, z, y, C[s + 12], 6, 1700485571);
			y = i(y, B, A, z, C[s + 3], 10, -1894986606);
			z = i(z, y, B, A, C[s + 10], 15, -1051523);
			A = i(A, z, y, B, C[s + 1], 21, -2054922799);
			B = i(B, A, z, y, C[s + 8], 6, 1873313359);
			y = i(y, B, A, z, C[s + 15], 10, -30611744);
			z = i(z, y, B, A, C[s + 6], 15, -1560198380);
			A = i(A, z, y, B, C[s + 13], 21, 1309151649);
			B = i(B, A, z, y, C[s + 4], 6, -145523070);
			y = i(y, B, A, z, C[s + 11], 10, -1120210379);
			z = i(z, y, B, A, C[s + 2], 15, 718787259);
			A = i(A, z, y, B, C[s + 9], 21, -343485551);
			B = j(B, v);
			A = j(A, u);
			z = j(z, t);
			y = j(y, r)
		}
		return [B, A, z, y]
	};
	var e = function (t, w) {
		var v = b(t);
		if (v.length > 16) {
			v = f(v, t.length * l)
		}
		var r = new Array(16),
		u = new Array(16);
		for (var s = 0; s < 16; s++) {
			r[s] = v[s]^909522486;
			u[s] = v[s]^1549556828
		}
		var x = f(r.concat(b(w)), 512 + w.length * l);
		return f(u.concat(x), 512 + 128)
	};
	var h = {
		hexdigest : function (r) {
			return q(f(b(r), r.length * l))
		},
		b64digest : function (r) {
			return p(f(b(r), r.length * l))
		},
		hash : function (r) {
			return g(f(b(r), r.length * l))
		},
		hmac_hexdigest : function (r, s) {
			return q(e(r, s))
		},
		hmac_b64digest : function (r, s) {
			return p(e(r, s))
		},
		hmac_hash : function (r, s) {
			return g(e(r, s))
		},
		test : function () {
			return MD5.hexdigest("abc") === "900150983cd24fb0d6963f7d28e17f72"
		}
	};
	return h
})();
if (!Function.prototype.bind) {
	Function.prototype.bind = function (b) {
		var a = this;
		return function () {
			return a.apply(b, arguments)
		}
	}
}
if (!Function.prototype.prependArg) {
	Function.prototype.prependArg = function (a) {
		var b = this;
		return function () {
			var d = [a];
			for (var c = 0; c < arguments.length; c++) {
				d.push(arguments[c])
			}
			return b.apply(this, d)
		}
	}
}
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function (b) {
		var a = this.length;
		var c = Number(arguments[1]) || 0;
		c = (c < 0) ? Math.ceil(c) : Math.floor(c);
		if (c < 0) {
			c += a
		}
		for (; c < a; c++) {
			if (c in this && this[c] === b) {
				return c
			}
		}
		return -1
	}
}
(function (f) {
	var e;
	function c(h, g) {
		return new e.Builder(h, g)
	}
	function a(g) {
		return new e.Builder("message", g)
	}
	function d(g) {
		return new e.Builder("iq", g)
	}
	function b(g) {
		return new e.Builder("presence", g)
	}
	e = {
		VERSION : "1.0.1",
		NS : {
			HTTPBIND : "http://jabber.org/protocol/httpbind",
			BOSH : "urn:xmpp:xbosh",
			CLIENT : "jabber:client",
			AUTH : "jabber:iq:auth",
			ROSTER : "jabber:iq:roster",
			PROFILE : "jabber:iq:profile",
			DISCO_INFO : "http://jabber.org/protocol/disco#info",
			DISCO_ITEMS : "http://jabber.org/protocol/disco#items",
			MUC : "http://jabber.org/protocol/muc",
			SASL : "urn:ietf:params:xml:ns:xmpp-sasl",
			STREAM : "http://etherx.jabber.org/streams",
			BIND : "urn:ietf:params:xml:ns:xmpp-bind",
			SESSION : "urn:ietf:params:xml:ns:xmpp-session",
			VERSION : "jabber:iq:version",
			STANZAS : "urn:ietf:params:xml:ns:xmpp-stanzas"
		},
		addNamespace : function (g, h) {
			e.NS[g] = h
		},
		Status : {
			ERROR : 0,
			CONNECTING : 1,
			CONNFAIL : 2,
			AUTHENTICATING : 3,
			AUTHFAIL : 4,
			CONNECTED : 5,
			DISCONNECTED : 6,
			DISCONNECTING : 7,
			ATTACHED : 8
		},
		LogLevel : {
			DEBUG : 0,
			INFO : 1,
			WARN : 2,
			ERROR : 3,
			FATAL : 4
		},
		ElementType : {
			NORMAL : 1,
			TEXT : 3
		},
		TIMEOUT : 1.1,
		SECONDARY_TIMEOUT : 0.1,
		forEachChild : function (k, l, j) {
			var h,
			g;
			for (h = 0; h < k.childNodes.length; h++) {
				g = k.childNodes[h];
				if (g.nodeType == e.ElementType.NORMAL && (!l || this.isTagEqual(g, l))) {
					j(g)
				}
			}
		},
		isTagEqual : function (h, g) {
			return h.tagName.toLowerCase() == g.toLowerCase()
		},
		_xmlGenerator : null,
		_makeGenerator : function () {
			var g;
			if (window.ActiveXObject) {
				g = new ActiveXObject("Microsoft.XMLDOM");
				g.appendChild(g.createElement("strophe"))
			} else {
				g = document.implementation.createDocument("jabber:client", "strophe", null)
			}
			return g
		},
		xmlElement : function (j) {
			if (!j) {
				return null
			}
			var m = null;
			if (!e._xmlGenerator) {
				e._xmlGenerator = e._makeGenerator()
			}
			m = e._xmlGenerator.createElement(j);
			var g,
			l,
			h;
			for (g = 1; g < arguments.length; g++) {
				if (!arguments[g]) {
					continue
				}
				if (typeof(arguments[g]) == "string" || typeof(arguments[g]) == "number") {
					m.appendChild(e.xmlTextNode(arguments[g]))
				} else {
					if (typeof(arguments[g]) == "object" && typeof(arguments[g].sort) == "function") {
						for (l = 0; l < arguments[g].length; l++) {
							if (typeof(arguments[g][l]) == "object" && typeof(arguments[g][l].sort) == "function") {
								m.setAttribute(arguments[g][l][0], arguments[g][l][1])
							}
						}
					} else {
						if (typeof(arguments[g]) == "object") {
							for (h in arguments[g]) {
								if (arguments[g].hasOwnProperty(h)) {
									m.setAttribute(h, arguments[g][h])
								}
							}
						}
					}
				}
			}
			return m
		},
		xmlescape : function (g) {
			g = g.replace(/\&/g, "&amp;");
			g = g.replace(/</g, "&lt;");
			g = g.replace(/>/g, "&gt;");
			return g
		},
		xmlTextNode : function (g) {
			g = e.xmlescape(g);
			if (!e._xmlGenerator) {
				e._xmlGenerator = e._makeGenerator()
			}
			return e._xmlGenerator.createTextNode(g)
		},
		getText : function (h) {
			if (!h) {
				return null
			}
			var j = "";
			if (h.childNodes.length === 0 && h.nodeType == e.ElementType.TEXT) {
				j += h.nodeValue
			}
			for (var g = 0; g < h.childNodes.length; g++) {
				if (h.childNodes[g].nodeType == e.ElementType.TEXT) {
					j += h.childNodes[g].nodeValue
				}
			}
			return j
		},
		copyElement : function (j) {
			var g,
			h;
			if (j.nodeType == e.ElementType.NORMAL) {
				h = e.xmlElement(j.tagName);
				for (g = 0; g < j.attributes.length; g++) {
					h.setAttribute(j.attributes[g].nodeName.toLowerCase(), j.attributes[g].value)
				}
				for (g = 0; g < j.childNodes.length; g++) {
					h.appendChild(e.copyElement(j.childNodes[g]))
				}
			} else {
				if (j.nodeType == e.ElementType.TEXT) {
					h = e.xmlTextNode(j.nodeValue)
				}
			}
			return h
		},
		escapeNode : function (g) {
			return g.replace(/^\s+|\s+$/g, "").replace(/\\/g, "\\5c").replace(/ /g, "\\20").replace(/\"/g, "\\22").replace(/\&/g, "\\26").replace(/\'/g, "\\27").replace(/\//g, "\\2f").replace(/:/g, "\\3a").replace(/</g, "\\3c").replace(/>/g, "\\3e").replace(/@/g, "\\40")
		},
		unescapeNode : function (g) {
			return g.replace(/\\20/g, " ").replace(/\\22/g, '"').replace(/\\26/g, "&").replace(/\\27/g, "'").replace(/\\2f/g, "/").replace(/\\3a/g, ":").replace(/\\3c/g, "<").replace(/\\3e/g, ">").replace(/\\40/g, "@").replace(/\\5c/g, "\\")
		},
		getNodeFromJid : function (g) {
			if (g.indexOf("@") < 0) {
				return null
			}
			return g.split("@")[0]
		},
		getDomainFromJid : function (g) {
			var h = e.getBareJidFromJid(g);
			if (h.indexOf("@") < 0) {
				return h
			} else {
				var i = h.split("@");
				i.splice(0, 1);
				return i.join("@")
			}
		},
		getResourceFromJid : function (g) {
			var h = g.split("/");
			if (h.length < 2) {
				return null
			}
			h.splice(0, 1);
			return h.join("/")
		},
		getBareJidFromJid : function (g) {
			return g.split("/")[0]
		},
		log : function (h, g) {
			return
		},
		debug : function (g) {
			this.log(this.LogLevel.DEBUG, g)
		},
		info : function (g) {
			this.log(this.LogLevel.INFO, g)
		},
		warn : function (g) {
			this.log(this.LogLevel.WARN, g)
		},
		error : function (g) {
			this.log(this.LogLevel.ERROR, g)
		},
		fatal : function (g) {
			this.log(this.LogLevel.FATAL, g)
		},
		serialize : function (j) {
			var g;
			if (!j) {
				return null
			}
			if (typeof(j.tree) === "function") {
				j = j.tree()
			}
			var l = j.nodeName;
			var h,
			k;
			if (j.getAttribute("_realname")) {
				l = j.getAttribute("_realname")
			}
			g = "<" + l;
			for (h = 0; h < j.attributes.length; h++) {
				if (j.attributes[h].nodeName != "_realname") {
					g += " " + j.attributes[h].nodeName.toLowerCase() + "='" + j.attributes[h].value.replace("&", "&amp;").replace("'", "&apos;").replace("<", "&lt;") + "'"
				}
			}
			if (j.childNodes.length > 0) {
				g += ">";
				for (h = 0; h < j.childNodes.length; h++) {
					k = j.childNodes[h];
					if (k.nodeType == e.ElementType.NORMAL) {
						g += e.serialize(k)
					} else {
						if (k.nodeType == e.ElementType.TEXT) {
							g += k.nodeValue
						}
					}
				}
				g += "</" + l + ">"
			} else {
				g += "/>"
			}
			return g
		},
		_requestId : 0,
		_connectionPlugins : {},
		addConnectionPlugin : function (g, h) {
			e._connectionPlugins[g] = h
		}
	};
	e.Builder = function (h, g) {
		if (h == "presence" || h == "message" || h == "iq") {
			if (g && !g.xmlns) {
				g.xmlns = e.NS.CLIENT
			} else {
				if (!g) {
					g = {
						xmlns : e.NS.CLIENT
					}
				}
			}
		}
		this.nodeTree = e.xmlElement(h, g);
		this.node = this.nodeTree
	};
	e.Builder.prototype = {
		tree : function () {
			return this.nodeTree
		},
		toString : function () {
			return e.serialize(this.nodeTree)
		},
		up : function () {
			this.node = this.node.parentNode;
			return this
		},
		attrs : function (h) {
			for (var g in h) {
				if (h.hasOwnProperty(g)) {
					this.node.setAttribute(g, h[g])
				}
			}
			return this
		},
		c : function (h, g) {
			var i = e.xmlElement(h, g);
			this.node.appendChild(i);
			this.node = i;
			return this
		},
		cnode : function (g) {
			this.node.appendChild(g);
			this.node = g;
			return this
		},
		t : function (g) {
			var h = e.xmlTextNode(g);
			this.node.appendChild(h);
			return this
		}
	};
	e.Handler = function (k, j, h, i, m, l, g) {
		this.handler = k;
		this.ns = j;
		this.name = h;
		this.type = i;
		this.id = m;
		this.options = g || {
			matchbare : false
		};
		if (!this.options.matchBare) {
			this.options.matchBare = false
		}
		if (this.options.matchBare) {
			this.from = e.getBareJidFromJid(l)
		} else {
			this.from = l
		}
		this.user = true
	};
	e.Handler.prototype = {
		isMatch : function (h) {
			var j;
			var i = null;
			if (this.options.matchBare) {
				i = e.getBareJidFromJid(h.getAttribute("from"))
			} else {
				i = h.getAttribute("from")
			}
			j = false;
			if (!this.ns) {
				j = true
			} else {
				var g = this;
				e.forEachChild(h, null, function (k) {
					if (k.getAttribute("xmlns") == g.ns) {
						j = true
					}
				});
				j = j || h.getAttribute("xmlns") == this.ns
			}
			if (j && (!this.name || e.isTagEqual(h, this.name)) && (!this.type || h.getAttribute("type") === this.type) && (!this.id || h.getAttribute("id") === this.id) && (!this.from || i === this.from)) {
				return true
			}
			return false
		},
		run : function (h) {
			var g = null;
			try {
				g = this.handler(h)
			} catch (i) {
				if (i.sourceURL) {
					e.fatal("error: " + this.handler + " " + i.sourceURL + ":" + i.line + " - " + i.name + ": " + i.message)
				} else {
					if (i.fileName) {
						if (typeof(console) != "undefined") {
							console.trace();
							console.error(this.handler, " - error - ", i, i.message)
						}
						e.fatal("error: " + this.handler + " " + i.fileName + ":" + i.lineNumber + " - " + i.name + ": " + i.message)
					} else {
						e.fatal("error: " + this.handler)
					}
				}
				throw i
			}
			return g
		},
		toString : function () {
			return "{Handler: " + this.handler + "(" + this.name + "," + this.id + "," + this.ns + ")}"
		}
	};
	e.TimedHandler = function (h, g) {
		this.period = h;
		this.handler = g;
		this.lastCalled = new Date().getTime();
		this.user = true
	};
	e.TimedHandler.prototype = {
		run : function () {
			this.lastCalled = new Date().getTime();
			return this.handler()
		},
		reset : function () {
			this.lastCalled = new Date().getTime()
		},
		toString : function () {
			return "{TimedHandler: " + this.handler + "(" + this.period + ")}"
		}
	};
	e.Request = function (i, h, g, j) {
		this.id = ++e._requestId;
		this.xmlData = i;
		this.data = e.serialize(i);
		this.origFunc = h;
		this.func = h;
		this.rid = g;
		this.date = NaN;
		this.sends = j || 0;
		this.abort = false;
		this.dead = null;
		this.age = function () {
			if (!this.date) {
				return 0
			}
			var k = new Date();
			return (k - this.date) / 1000
		};
		this.timeDead = function () {
			if (!this.dead) {
				return 0
			}
			var k = new Date();
			return (k - this.dead) / 1000
		};
		this.xhr = this._newXHR()
	};
	e.Request.prototype = {
		getResponse : function () {
			var g = null;
			if (this.xhr.responseXML && this.xhr.responseXML.documentElement) {
				g = this.xhr.responseXML.documentElement;
				if (g.tagName == "parsererror") {
					e.error("invalid response received");
					e.error("responseText: " + this.xhr.responseText);
					e.error("responseXML: " + e.serialize(this.xhr.responseXML));
					throw "parsererror"
				}
			} else {
				if (this.xhr.responseText) {
					e.error("invalid response received");
					e.error("responseText: " + this.xhr.responseText);
					e.error("responseXML: " + e.serialize(this.xhr.responseXML))
				}
			}
			return g
		},
		_newXHR : function () {
			var g = null;
			if (window.XMLHttpRequest) {
				g = new XMLHttpRequest();
				if (g.overrideMimeType) {
					g.overrideMimeType("text/xml")
				}
			} else {
				if (window.ActiveXObject) {
					g = new ActiveXObject("Microsoft.XMLHTTP")
				}
			}
			g.onreadystatechange = this.func.prependArg(this);
			return g
		}
	};
	e.Connection = function (g) {
		this.service = g;
		this.jid = "";
		this.rid = Math.floor(Math.random() * 4294967295);
		this.sid = null;
		this.streamId = null;
		this.do_session = false;
		this.do_bind = false;
		this.timedHandlers = [];
		this.handlers = [];
		this.removeTimeds = [];
		this.removeHandlers = [];
		this.addTimeds = [];
		this.addHandlers = [];
		this._idleTimeout = null;
		this._disconnectTimeout = null;
		this.authenticated = false;
		this.disconnecting = false;
		this.connected = false;
		this.errors = 0;
		this.paused = false;
		this.hold = 1;
		this.wait = 60;
		this.window = 5;
		this._data = [];
		this._requests = [];
		this._uniqueId = Math.round(Math.random() * 10000);
		this._sasl_success_handler = null;
		this._sasl_failure_handler = null;
		this._sasl_challenge_handler = null;
		this._idleTimeout = setTimeout(this._onIdle.bind(this), 100);
		for (var h in e._connectionPlugins) {
			if (e._connectionPlugins.hasOwnProperty(h)) {
				var j = e._connectionPlugins[h];
				var i = function () {};
				i.prototype = j;
				this[h] = new i();
				this[h].init(this)
			}
		}
	};
	e.Connection.prototype = {
		reset : function () {
			this.rid = Math.floor(Math.random() * 4294967295);
			this.sid = null;
			this.streamId = null;
			this.do_session = false;
			this.do_bind = false;
			this.timedHandlers = [];
			this.handlers = [];
			this.removeTimeds = [];
			this.removeHandlers = [];
			this.addTimeds = [];
			this.addHandlers = [];
			this.authenticated = false;
			this.disconnecting = false;
			this.connected = false;
			this.errors = 0;
			this._requests = [];
			this._uniqueId = Math.round(Math.random() * 10000)
		},
		pause : function () {
			this.paused = true
		},
		resume : function () {
			this.paused = false
		},
		getUniqueId : function (g) {
			if (typeof(g) == "string" || typeof(g) == "number") {
				return ++this._uniqueId + ":" + g
			} else {
				return ++this._uniqueId + ""
			}
		},
		connect : function (h, i, l, k, j) {
			this.jid = h;
			this.pass = i;
			this.connect_callback = l;
			this.disconnecting = false;
			this.connected = false;
			this.authenticated = false;
			this.errors = 0;
			this.wait = k || this.wait;
			this.hold = j || this.hold;
			this.domain = e.getDomainFromJid(this.jid);
			var g = this._buildBody().attrs({
					to : this.domain,
					"xml:lang" : "en",
					wait : this.wait,
					hold : this.hold,
					content : "text/xml; charset=utf-8",
					ver : "1.6",
					"xmpp:version" : "1.0",
					"xmlns:xmpp" : e.NS.BOSH
				});
			this._changeConnectStatus(e.Status.CONNECTING, null);
			this._requests.push(new e.Request(g.tree(), this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)), g.tree().getAttribute("rid")));
			this._throttledRequestHandler()
		},
		attach : function (i, g, j, m, l, k, h) {
			this.jid = i;
			this.sid = g;
			this.rid = j;
			this.connect_callback = m;
			this.domain = e.getDomainFromJid(this.jid);
			this.authenticated = true;
			this.connected = true;
			this.wait = l || this.wait;
			this.hold = k || this.hold;
			this.window = h || this.window;
			this._changeConnectStatus(e.Status.ATTACHED, null)
		},
		xmlInput : function (g) {
			return
		},
		xmlOutput : function (g) {
			return
		},
		rawInput : function (g) {
			return
		},
		rawOutput : function (g) {
			return
		},
		send : function (h) {
			if (h === null) {
				return
			}
			if (typeof(h.sort) === "function") {
				for (var g = 0; g < h.length; g++) {
					this._queueData(h[g])
				}
			} else {
				if (typeof(h.tree) === "function") {
					this._queueData(h.tree())
				} else {
					this._queueData(h)
				}
			}
			this._throttledRequestHandler();
			clearTimeout(this._idleTimeout);
			this._idleTimeout = setTimeout(this._onIdle.bind(this), 100)
		},
		flush : function () {
			clearTimeout(this._idleTimeout);
			this._onIdle()
		},
		sendIQ : function (j, n, g, k) {
			var l = null;
			var i = this;
			if (typeof(j.tree) === "function") {
				j = j.tree()
			}
			var m = j.getAttribute("id");
			if (!m) {
				m = this.getUniqueId("sendIQ");
				j.setAttribute("id", m)
			}
			var h = this.addHandler(function (p) {
					if (l) {
						i.deleteTimedHandler(l)
					}
					var o = p.getAttribute("type");
					if (o === "result") {
						if (n) {
							n(p)
						}
					} else {
						if (o === "error") {
							if (g) {
								g(p)
							}
						} else {
							throw {
								name : "StropheError",
								message : "Got bad IQ type of " + o
							}
						}
					}
				}, null, "iq", null, m);
			if (k) {
				l = this.addTimedHandler(k, function () {
						i.deleteHandler(h);
						if (g) {
							g(null)
						}
						return false
					})
			}
			this.send(j);
			return m
		},
		_queueData : function (g) {
			if (g === null || !g.tagName || !g.childNodes) {
				throw {
					name : "StropheError",
					message : "Cannot queue non-DOMElement."
				}
			}
			this._data.push(g)
		},
		_sendRestart : function () {
			this._data.push("restart");
			this._throttledRequestHandler();
			clearTimeout(this._idleTimeout);
			this._idleTimeout = setTimeout(this._onIdle.bind(this), 100)
		},
		addTimedHandler : function (i, h) {
			var g = new e.TimedHandler(i, h);
			this.addTimeds.push(g);
			return g
		},
		deleteTimedHandler : function (g) {
			this.removeTimeds.push(g)
		},
		addHandler : function (l, k, i, j, n, m, h) {
			var g = new e.Handler(l, k, i, j, n, m, h);
			this.addHandlers.push(g);
			return g
		},
		deleteHandler : function (g) {
			this.removeHandlers.push(g)
		},
		disconnect : function (g) {
			this._changeConnectStatus(e.Status.DISCONNECTING, g);
			e.info("Disconnect was called because: " + g);
			if (this.connected) {
				this._disconnectTimeout = this._addSysTimedHandler(3000, this._onDisconnectTimeout.bind(this));
				this._sendTerminate()
			}
		},
		_changeConnectStatus : function (g, m) {
			for (var h in e._connectionPlugins) {
				if (e._connectionPlugins.hasOwnProperty(h)) {
					var j = this[h];
					if (j.statusChanged) {
						try {
							j.statusChanged(g, m)
						} catch (i) {
							e.error("" + h + " plugin caused an exception changing status: " + i)
						}
					}
				}
			}
			if (this.connect_callback) {
				try {
					this.connect_callback(g, m)
				} catch (l) {
					e.error("User connection callback caused an exception: " + l)
				}
			}
		},
		_buildBody : function () {
			var g = c("body", {
					rid : this.rid++,
					xmlns : e.NS.HTTPBIND
				});
			if (this.sid !== null) {
				g.attrs({
					sid : this.sid
				})
			}
			return g
		},
		_removeRequest : function (h) {
			e.debug("removing request");
			var g;
			for (g = this._requests.length - 1; g >= 0; g--) {
				if (h == this._requests[g]) {
					this._requests.splice(g, 1)
				}
			}
			h.xhr.onreadystatechange = function () {};
			this._throttledRequestHandler()
		},
		_restartRequest : function (g) {
			var h = this._requests[g];
			if (h.dead === null) {
				h.dead = new Date()
			}
			this._processRequest(g)
		},
		_processRequest : function (j) {
			var o = this._requests[j];
			var r = -1;
			try {
				if (o.xhr.readyState == 4) {
					r = o.xhr.status
				}
			} catch (m) {
				e.error("caught an error in _requests[" + j + "], reqStatus: " + r)
			}
			if (typeof(r) == "undefined") {
				r = -1
			}
			var h = o.age();
			var g = (!isNaN(h) && h > Math.floor(e.TIMEOUT * this.wait));
			var k = (o.dead !== null && o.timeDead() > Math.floor(e.SECONDARY_TIMEOUT * this.wait));
			var q = (o.xhr.readyState == 4 && (r < 1 || r >= 500));
			if (g || k || q) {
				if (k) {
					e.error("Request " + this._requests[j].id + " timed out (secondary), restarting")
				}
				o.abort = true;
				o.xhr.abort();
				o.xhr.onreadystatechange = function () {};
				this._requests[j] = new e.Request(o.xmlData, o.origFunc, o.rid, o.sends);
				o = this._requests[j]
			}
			if (o.xhr.readyState === 0) {
				e.debug("request id " + o.id + "." + o.sends + " posting");
				o.date = new Date();
				try {
					o.xhr.open("POST", this.service, true)
				} catch (n) {
					e.error("XHR open failed.");
					if (!this.connected) {
						this._changeConnectStatus(e.Status.CONNFAIL, "bad-service")
					}
					this.disconnect();
					return
				}
				var p = function () {
					o.xhr.send(o.data)
				};
				if (o.sends > 1) {
					var l = Math.pow(o.sends, 3) * 1000;
					setTimeout(p, l)
				} else {
					p()
				}
				o.sends++;
				this.xmlOutput(o.xmlData);
				this.rawOutput(o.data)
			} else {
				e.debug("_processRequest: " + (j === 0 ? "first" : "second") + " request has readyState of " + o.xhr.readyState)
			}
		},
		_throttledRequestHandler : function () {
			if (!this._requests) {
				e.debug("_throttledRequestHandler called with undefined requests")
			} else {
				e.debug("_throttledRequestHandler called with " + this._requests.length + " requests")
			}
			if (!this._requests || this._requests.length === 0) {
				return
			}
			if (this._requests.length > 0) {
				this._processRequest(0)
			}
			if (this._requests.length > 1 && Math.abs(this._requests[0].rid - this._requests[1].rid) < this.window - 1) {
				this._processRequest(1)
			}
		},
		_onRequestStateChange : function (j, i) {
			e.debug("request id " + i.id + "." + i.sends + " state changed to " + i.xhr.readyState);
			if (i.abort) {
				i.abort = false;
				return
			}
			var h;
			if (i.xhr.readyState == 4) {
				h = 0;
				try {
					h = i.xhr.status
				} catch (k) {}

				if (typeof(h) == "undefined") {
					h = 0
				}
				if (this.disconnecting) {
					if (h >= 400) {
						this._hitError(h);
						return
					}
				}
				var g = (this._requests[0] == i);
				var l = (this._requests[1] == i);
				if ((h > 0 && h < 500) || i.sends > 5) {
					this._removeRequest(i);
					e.debug("request id " + i.id + " should now be removed")
				}
				if (h == 200) {
					if (l || (g && this._requests.length > 0 && this._requests[0].age() > Math.floor(e.SECONDARY_TIMEOUT * this.wait))) {
						this._restartRequest(0)
					}
					e.debug("request id " + i.id + "." + i.sends + " got 200");
					j(i);
					this.errors = 0
				} else {
					e.error("request id " + i.id + "." + i.sends + " error " + h + " happened");
					if (h === 0 || (h >= 400 && h < 600) || h >= 12000) {
						this._hitError(h);
						if (h >= 400 && h < 500) {
							this._changeConnectStatus(e.Status.DISCONNECTING, null);
							this._doDisconnect()
						}
					}
				}
				if (!((h > 0 && h < 10000) || i.sends > 5)) {
					this._throttledRequestHandler()
				}
			}
		},
		_hitError : function (g) {
			this.errors++;
			e.warn("request errored, status: " + g + ", number of errors: " + this.errors);
			if (this.errors > 4) {
				this._onDisconnectTimeout()
			}
		},
		_doDisconnect : function () {
			e.info("_doDisconnect was called");
			this.authenticated = false;
			this.disconnecting = false;
			this.sid = null;
			this.streamId = null;
			this.rid = Math.floor(Math.random() * 4294967295);
			if (this.connected) {
				this._changeConnectStatus(e.Status.DISCONNECTED, null);
				this.connected = false
			}
			this.handlers = [];
			this.timedHandlers = [];
			this.removeTimeds = [];
			this.removeHandlers = [];
			this.addTimeds = [];
			this.addHandlers = []
		},
		_dataRecv : function (o) {
			try {
				var g = o.getResponse()
			} catch (m) {
				if (m != "parsererror") {
					throw m
				}
				this.disconnect("strophe-parsererror")
			}
			if (g === null) {
				return
			}
			this.xmlInput(g);
			this.rawInput(e.serialize(g));
			var l,
			j;
			while (this.removeHandlers.length > 0) {
				j = this.removeHandlers.pop();
				l = this.handlers.indexOf(j);
				if (l >= 0) {
					this.handlers.splice(l, 1)
				}
			}
			while (this.addHandlers.length > 0) {
				this.handlers.push(this.addHandlers.pop())
			}
			if (this.disconnecting && this._requests.length === 0) {
				this.deleteTimedHandler(this._disconnectTimeout);
				this._disconnectTimeout = null;
				this._doDisconnect();
				return
			}
			var h = g.getAttribute("type");
			var n,
			k;
			if (h !== null && h == "terminate") {
				n = g.getAttribute("condition");
				k = g.getElementsByTagName("conflict");
				if (n !== null) {
					if (n == "remote-stream-error" && k.length > 0) {
						n = "conflict"
					}
					this._changeConnectStatus(e.Status.CONNFAIL, n)
				} else {
					this._changeConnectStatus(e.Status.CONNFAIL, "unknown")
				}
				this.disconnect();
				return
			}
			var p = this;
			e.forEachChild(g, null, function (t) {
				var r,
				s;
				s = p.handlers;
				p.handlers = [];
				for (r = 0; r < s.length; r++) {
					var q = s[r];
					if (q.isMatch(t) && (p.authenticated || !q.user)) {
						if (q.run(t)) {
							p.handlers.push(q)
						}
					} else {
						p.handlers.push(q)
					}
				}
			})
		},
		_sendTerminate : function () {
			e.info("_sendTerminate was called");
			var g = this._buildBody().attrs({
					type : "terminate"
				});
			if (this.authenticated) {
				g.c("presence", {
					xmlns : e.NS.CLIENT,
					type : "unavailable"
				})
			}
			this.disconnecting = true;
			var h = new e.Request(g.tree(), this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)), g.tree().getAttribute("rid"));
			this._requests.push(h);
			this._throttledRequestHandler()
		},
		_connect_cb : function (v) {
			e.info("_connect_cb was called");
			this.connected = true;
			var h = v.getResponse();
			if (!h) {
				return
			}
			this.xmlInput(h);
			this.rawInput(e.serialize(h));
			var m = h.getAttribute("type");
			var u,
			o;
			if (m !== null && m == "terminate") {
				u = h.getAttribute("condition");
				o = h.getElementsByTagName("conflict");
				if (u !== null) {
					if (u == "remote-stream-error" && o.length > 0) {
						u = "conflict"
					}
					this._changeConnectStatus(e.Status.CONNFAIL, u)
				} else {
					this._changeConnectStatus(e.Status.CONNFAIL, "unknown")
				}
				return
			}
			if (!this.sid) {
				this.sid = h.getAttribute("sid")
			}
			if (!this.stream_id) {
				this.stream_id = h.getAttribute("authid")
			}
			var j = h.getAttribute("requests");
			if (j) {
				this.window = parseInt(j, 10)
			}
			var g = h.getAttribute("hold");
			if (g) {
				this.hold = parseInt(g, 10)
			}
			var q = h.getAttribute("wait");
			if (q) {
				this.wait = parseInt(q, 10)
			}
			var w = false;
			var l = false;
			var t = false;
			var x = h.getElementsByTagName("mechanism");
			var n,
			s,
			p,
			k;
			if (x.length > 0) {
				for (n = 0; n < x.length; n++) {
					s = e.getText(x[n]);
					if (s == "DIGEST-MD5") {
						l = true
					} else {
						if (s == "PLAIN") {
							w = true
						} else {
							if (s == "ANONYMOUS") {
								t = true
							}
						}
					}
				}
			} else {
				var r = this._buildBody();
				this._requests.push(new e.Request(r.tree(), this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)), r.tree().getAttribute("rid")));
				this._throttledRequestHandler();
				return
			}
			if (e.getNodeFromJid(this.jid) === null && t) {
				this._changeConnectStatus(e.Status.AUTHENTICATING, null);
				this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
				this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
				this.send(c("auth", {
						xmlns : e.NS.SASL,
						mechanism : "ANONYMOUS"
					}).tree())
			} else {
				if (e.getNodeFromJid(this.jid) === null) {
					this._changeConnectStatus(e.Status.CONNFAIL, "x-strophe-bad-non-anon-jid");
					this.disconnect()
				} else {
					if (l) {
						this._changeConnectStatus(e.Status.AUTHENTICATING, null);
						this._sasl_challenge_handler = this._addSysHandler(this._sasl_challenge1_cb.bind(this), null, "challenge", null, null);
						this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
						this.send(c("auth", {
								xmlns : e.NS.SASL,
								mechanism : "DIGEST-MD5"
							}).tree())
					} else {
						if (w) {
							p = e.getBareJidFromJid(this.jid);
							p = p + "\u0000";
							p = p + e.getNodeFromJid(this.jid);
							p = p + "\u0000";
							p = p + this.pass;
							this._changeConnectStatus(e.Status.AUTHENTICATING, null);
							this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
							this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
							k = Base64.encode(p);
							this.send(c("auth", {
									xmlns : e.NS.SASL,
									mechanism : "PLAIN"
								}).t(k).tree())
						} else {
							this._changeConnectStatus(e.Status.AUTHENTICATING, null);
							this._addSysHandler(this._auth1_cb.bind(this), null, null, null, "_auth_1");
							this.send(d({
									type : "get",
									to : this.domain,
									id : "_auth_1"
								}).c("query", {
									xmlns : e.NS.AUTH
								}).c("username", {}).t(e.getNodeFromJid(this.jid)).tree())
						}
					}
				}
			}
		},
		_sasl_challenge1_cb : function (k) {
			var h = /([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/;
			var q = Base64.decode(e.getText(k));
			var r = MD5.hexdigest(Math.random() * 1234567890);
			var n = "";
			var s = null;
			var o = "";
			var g = "";
			var m;
			this.deleteHandler(this._sasl_failure_handler);
			while (q.match(h)) {
				m = q.match(h);
				q = q.replace(m[0], "");
				m[2] = m[2].replace(/^"(.+)"$/, "$1");
				switch (m[1]) {
				case "realm":
					n = m[2];
					break;
				case "nonce":
					o = m[2];
					break;
				case "qop":
					g = m[2];
					break;
				case "host":
					s = m[2];
					break
				}
			}
			var l = "xmpp/" + this.domain;
			if (s !== null) {
				l = l + "/" + s
			}
			var j = MD5.hash(e.getNodeFromJid(this.jid) + ":" + n + ":" + this.pass) + ":" + o + ":" + r;
			var i = "AUTHENTICATE:" + l;
			var p = "";
			p += "username=" + this._quote(e.getNodeFromJid(this.jid)) + ",";
			p += "realm=" + this._quote(n) + ",";
			p += "nonce=" + this._quote(o) + ",";
			p += "cnonce=" + this._quote(r) + ",";
			p += 'nc="00000001",';
			p += 'qop="auth",';
			p += "digest-uri=" + this._quote(l) + ",";
			p += "response=" + this._quote(MD5.hexdigest(MD5.hexdigest(j) + ":" + o + ":00000001:" + r + ":auth:" + MD5.hexdigest(i))) + ",";
			p += 'charset="utf-8"';
			this._sasl_challenge_handler = this._addSysHandler(this._sasl_challenge2_cb.bind(this), null, "challenge", null, null);
			this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
			this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
			this.send(c("response", {
					xmlns : e.NS.SASL
				}).t(Base64.encode(p)).tree());
			return false
		},
		_quote : function (g) {
			return '"' + g.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"'
		},
		_sasl_challenge2_cb : function (g) {
			this.deleteHandler(this._sasl_success_handler);
			this.deleteHandler(this._sasl_failure_handler);
			this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
			this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
			this.send(c("response", {
					xmlns : e.NS.SASL
				}).tree());
			return false
		},
		_auth1_cb : function (g) {
			var h = d({
					type : "set",
					id : "_auth_2"
				}).c("query", {
					xmlns : e.NS.AUTH
				}).c("username", {}).t(e.getNodeFromJid(this.jid)).up().c("password").t(this.pass);
			if (!e.getResourceFromJid(this.jid)) {
				this.jid = e.getBareJidFromJid(this.jid) + "/strophe"
			}
			h.up().c("resource", {}).t(e.getResourceFromJid(this.jid));
			this._addSysHandler(this._auth2_cb.bind(this), null, null, null, "_auth_2");
			this.send(h.tree());
			return false
		},
		_sasl_success_cb : function (g) {
			e.info("SASL authentication succeeded.");
			this.deleteHandler(this._sasl_failure_handler);
			this._sasl_failure_handler = null;
			if (this._sasl_challenge_handler) {
				this.deleteHandler(this._sasl_challenge_handler);
				this._sasl_challenge_handler = null
			}
			this._addSysHandler(this._sasl_auth1_cb.bind(this), null, "stream:features", null, null);
			this._sendRestart();
			return false
		},
		_sasl_auth1_cb : function (h) {
			var g,
			k;
			for (g = 0; g < h.childNodes.length; g++) {
				k = h.childNodes[g];
				if (k.nodeName == "bind") {
					this.do_bind = true
				}
				if (k.nodeName == "session") {
					this.do_session = true
				}
			}
			if (!this.do_bind) {
				this._changeConnectStatus(e.Status.AUTHFAIL, null);
				return false
			} else {
				this._addSysHandler(this._sasl_bind_cb.bind(this), null, null, null, "_bind_auth_2");
				var j = e.getResourceFromJid(this.jid);
				if (j) {
					this.send(d({
							type : "set",
							id : "_bind_auth_2"
						}).c("bind", {
							xmlns : e.NS.BIND
						}).c("resource", {}).t(j).tree())
				} else {
					this.send(d({
							type : "set",
							id : "_bind_auth_2"
						}).c("bind", {
							xmlns : e.NS.BIND
						}).tree())
				}
			}
			return false
		},
		_sasl_bind_cb : function (g) {
			if (g.getAttribute("type") == "error") {
				e.info("SASL binding failed.");
				this._changeConnectStatus(e.Status.AUTHFAIL, null);
				return false
			}
			var i = g.getElementsByTagName("bind");
			var h;
			if (i.length > 0) {
				h = i[0].getElementsByTagName("jid");
				if (h.length > 0) {
					this.jid = e.getText(h[0]);
					if (this.do_session) {
						this._addSysHandler(this._sasl_session_cb.bind(this), null, null, null, "_session_auth_2");
						this.send(d({
								type : "set",
								id : "_session_auth_2"
							}).c("session", {
								xmlns : e.NS.SESSION
							}).tree())
					} else {
						this.authenticated = true;
						this._changeConnectStatus(e.Status.CONNECTED, null)
					}
				}
			} else {
				e.info("SASL binding failed.");
				this._changeConnectStatus(e.Status.AUTHFAIL, null);
				return false
			}
		},
		_sasl_session_cb : function (g) {
			if (g.getAttribute("type") == "result") {
				this.authenticated = true;
				this._changeConnectStatus(e.Status.CONNECTED, null)
			} else {
				if (g.getAttribute("type") == "error") {
					e.info("Session creation failed.");
					this._changeConnectStatus(e.Status.AUTHFAIL, null);
					return false
				}
			}
			return false
		},
		_sasl_failure_cb : function (g) {
			if (this._sasl_success_handler) {
				this.deleteHandler(this._sasl_success_handler);
				this._sasl_success_handler = null
			}
			if (this._sasl_challenge_handler) {
				this.deleteHandler(this._sasl_challenge_handler);
				this._sasl_challenge_handler = null
			}
			this._changeConnectStatus(e.Status.AUTHFAIL, null);
			return false
		},
		_auth2_cb : function (g) {
			if (g.getAttribute("type") == "result") {
				this.authenticated = true;
				this._changeConnectStatus(e.Status.CONNECTED, null)
			} else {
				if (g.getAttribute("type") == "error") {
					this._changeConnectStatus(e.Status.AUTHFAIL, null);
					this.disconnect()
				}
			}
			return false
		},
		_addSysTimedHandler : function (i, h) {
			var g = new e.TimedHandler(i, h);
			g.user = false;
			this.addTimeds.push(g);
			return g
		},
		_addSysHandler : function (k, j, h, i, l) {
			var g = new e.Handler(k, j, h, i, l);
			g.user = false;
			this.addHandlers.push(g);
			return g
		},
		_onDisconnectTimeout : function () {
			e.info("_onDisconnectTimeout was called");
			var g;
			while (this._requests.length > 0) {
				g = this._requests.pop();
				g.abort = true;
				g.xhr.abort();
				g.xhr.onreadystatechange = function () {}

			}
			this._doDisconnect();
			return false
		},
		_onIdle : function () {
			var j,
			l,
			n,
			k;
			while (this.removeTimeds.length > 0) {
				l = this.removeTimeds.pop();
				j = this.timedHandlers.indexOf(l);
				if (j >= 0) {
					this.timedHandlers.splice(j, 1)
				}
			}
			while (this.addTimeds.length > 0) {
				this.timedHandlers.push(this.addTimeds.pop())
			}
			var h = new Date().getTime();
			k = [];
			for (j = 0; j < this.timedHandlers.length; j++) {
				l = this.timedHandlers[j];
				if (this.authenticated || !l.user) {
					n = l.lastCalled + l.period;
					if (n - h <= 0) {
						if (l.run()) {
							k.push(l)
						}
					} else {
						k.push(l)
					}
				}
			}
			this.timedHandlers = k;
			var g,
			m;
			if (this.authenticated && this._requests.length === 0 && this._data.length === 0 && !this.disconnecting) {
				e.info("no requests during idle cycle, sending blank request");
				this._data.push(null)
			}
			if (this._requests.length < 2 && this._data.length > 0 && !this.paused) {
				g = this._buildBody();
				for (j = 0; j < this._data.length; j++) {
					if (this._data[j] !== null) {
						if (this._data[j] === "restart") {
							g.attrs({
								to : this.domain,
								"xml:lang" : "en",
								"xmpp:restart" : "true",
								"xmlns:xmpp" : e.NS.BOSH
							})
						} else {
							g.cnode(this._data[j]).up()
						}
					}
				}
				delete this._data;
				this._data = [];
				this._requests.push(new e.Request(g.tree(), this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)), g.tree().getAttribute("rid")));
				this._processRequest(this._requests.length - 1)
			}
			if (this._requests.length > 0) {
				m = this._requests[0].age();
				if (this._requests[0].dead !== null) {
					if (this._requests[0].timeDead() > Math.floor(e.SECONDARY_TIMEOUT * this.wait)) {
						this._throttledRequestHandler()
					}
				}
				if (m > Math.floor(e.TIMEOUT * this.wait)) {
					e.warn("Request " + this._requests[0].id + " timed out, over " + Math.floor(e.TIMEOUT * this.wait) + " seconds since last activity");
					this._throttledRequestHandler()
				}
			}
			clearTimeout(this._idleTimeout);
			this._idleTimeout = setTimeout(this._onIdle.bind(this), 100)
		}
	};
	if (f) {
		f(e, c, a, d, b)
	}
})(function () {
	window.Strophe = arguments[0];
	window.$build = arguments[1];
	window.$msg = arguments[2];
	window.$iq = arguments[3];
	window.$pres = arguments[4]
});
Strophe.addConnectionPlugin("pubsub", {
	_connection : null,
	init : function (b) {
		this._connection = b;
		Strophe.addNamespace("PUBSUB", "http://jabber.org/protocol/pubsub");
		Strophe.addNamespace("PUBSUB_SUBSCRIBE_OPTIONS", Strophe.NS.PUBSUB + "#subscribe_options");
		Strophe.addNamespace("PUBSUB_ERRORS", Strophe.NS.PUBSUB + "#errors");
		Strophe.addNamespace("PUBSUB_EVENT", Strophe.NS.PUBSUB + "#event");
		Strophe.addNamespace("PUBSUB_OWNER", Strophe.NS.PUBSUB + "#owner");
		Strophe.addNamespace("PUBSUB_AUTO_CREATE", Strophe.NS.PUBSUB + "#auto-create");
		Strophe.addNamespace("PUBSUB_PUBLISH_OPTIONS", Strophe.NS.PUBSUB + "#publish-options");
		Strophe.addNamespace("PUBSUB_NODE_CONFIG", Strophe.NS.PUBSUB + "#node_config");
		Strophe.addNamespace("PUBSUB_CREATE_AND_CONFIGURE", Strophe.NS.PUBSUB + "#create-and-configure");
		Strophe.addNamespace("PUBSUB_SUBSCRIBE_AUTHORIZATION", Strophe.NS.PUBSUB + "#subscribe_authorization");
		Strophe.addNamespace("PUBSUB_GET_PENDING", Strophe.NS.PUBSUB + "#get-pending");
		Strophe.addNamespace("PUBSUB_MANAGE_SUBSCRIPTIONS", Strophe.NS.PUBSUB + "#manage-subscriptions");
		Strophe.addNamespace("PUBSUB_META_DATA", Strophe.NS.PUBSUB + "#meta-data")
	},
	createNode : function (B, u, z, i, y) {
		var x = this._connection.getUniqueId("pubsubcreatenode");
		var v = $iq({
				from : B,
				to : u,
				type : "set",
				id : x
			});
		var q = Strophe.xmlElement("configure", []);
		var s = Strophe.xmlElement("x", [["xmlns", "jabber:x:data"]]);
		var t = Strophe.xmlElement("field", [["var", "FORM_TYPE"], ["type", "hidden"]]);
		var r = Strophe.xmlElement("value", []);
		var p = Strophe.xmlTextNode(Strophe.NS.PUBSUB + "#node_config");
		r.appendChild(p);
		t.appendChild(r);
		s.appendChild(t);
		for (var w in i) {
			var A = i[w];
			s.appendChild(A)
		}
		if (i.length && i.length != 0) {
			q.appendChild(s)
		}
		v.c("pubsub", {
			xmlns : Strophe.NS.PUBSUB
		}).c("create", {
			node : z
		}).up().cnode(q);
		this._connection.addHandler(y, null, "iq", null, x, null);
		this._connection.send(v.tree());
		return x
	},
	subscribe : function (B, v, z, i, C, y) {
		var q = this._connection.getUniqueId("subscribenode");
		var x = Strophe.xmlElement("options", []);
		var t = Strophe.xmlElement("x", [["xmlns", "jabber:x:data"]]);
		var u = Strophe.xmlElement("field", [["var", "FORM_TYPE"], ["type", "hidden"]]);
		var s = Strophe.xmlElement("value", []);
		var r = Strophe.xmlTextNode(Strophe.NS.PUBSUB_SUBSCRIBE_OPTIONS);
		s.appendChild(r);
		u.appendChild(s);
		t.appendChild(u);
		var D = $iq({
				from : B,
				to : v,
				type : "set",
				id : q
			});
		if (i && i.length && i.length !== 0) {
			for (var w = 0; w < i.length; w++) {
				var A = i[w];
				t.appendChild(A)
			}
			x.appendChild(t);
			D.c("pubsub", {
				xmlns : Strophe.NS.PUBSUB
			}).c("subscribe", {
				node : z,
				jid : B
			}).up().cnode(x)
		} else {
			D.c("pubsub", {
				xmlns : Strophe.NS.PUBSUB
			}).c("subscribe", {
				node : z,
				jid : B
			})
		}
		this._connection.addHandler(y, null, "iq", null, q, null);
		this._connection.addHandler(C, null, "message", null, null, null);
		this._connection.send(D.tree());
		return q
	},
	unsubscribe : function (l, h, j, i) {
		var g = this._connection.getUniqueId("unsubscribenode");
		var k = $iq({
				from : l,
				to : h,
				type : "set",
				id : g
			});
		k.c("pubsub", {
			xmlns : Strophe.NS.PUBSUB
		}).c("unsubscribe", {
			node : j,
			jid : l
		});
		this._connection.addHandler(i, null, "iq", null, g, null);
		this._connection.send(k.tree());
		return g
	},
	publish : function (v, q, u, p, t) {
		var w = this._connection.getUniqueId("publishnode");
		var x = Strophe.xmlElement("publish", [["node", u], ["jid", v]]);
		for (var r in p) {
			var i = Strophe.xmlElement("item", []);
			var o = Strophe.xmlElement("entry", []);
			var n = Strophe.xmlTextNode(p[r]);
			o.appendChild(n);
			i.appendChild(o);
			x.appendChild(i)
		}
		var s = $iq({
				from : v,
				to : q,
				type : "set",
				id : w
			});
		s.c("pubsub", {
			xmlns : Strophe.NS.PUBSUB
		}).cnode(x);
		this._connection.addHandler(t, null, "iq", null, w, null);
		this._connection.send(s.tree());
		return w
	},
	items : function (g, h, k, j, i) {
		var l = $iq({
				from : g,
				to : h,
				type : "get"
			});
		l.c("pubsub", {
			xmlns : Strophe.NS.PUBSUB
		}).c("items", {
			node : k
		});
		return this._connection.sendIQ(l.tree(), j, i)
	}
});
function handleAjaxResp(a) {
	IdentificationId = a.d.NewSessionKey
}
var userAccountActivated = true;
function placeBid(b) {
	if (UserId > 0) {
		actionDone();
		var k = getPageWalletAmount(WalletId);
		if (!userAccountActivated) {
			var e = "#AccountActivationRequired";
			var i = jQuery(e).find(".buttonAction");
			alertActionCancel(e, i.text(), i.attr("href"));
			SafeTrackEvent("Bidding", "BidNotPlaced", "ACCOUNT_ACTIVATION_SOFT");
			return
		}
		if (k >= 1) {
			var d = "Auction_status_HOLD";
			var h = "Auction_status_WAITING_SERVER";
			var g = jQuery("#Auction_" + b);
			g.addClass(d);
			g.addClass(h);
			var j = g.find(".CurrentWinnerPublicName");
			var a = j.html();
			j.text(PublicName);
			var f = -1;
			var c = getTimeLeftObject(b);
			if (c != null) {
				f = c.timeLeft
			}
			jQuery.ajax({
				url : "/WebServices/BiddingWebService.asmx/PlaceBid",
				data : '{ "req": {"SessionKey": "' + IdentificationId + '","AuctionId": "' + b + '","Locale": "' + Locale + '"} }',
				dataType : "json",
				success : function (l) {
					handleAjaxResp(l);
					if (l && l.d && l.d.Success) {
						updateWalletAmount(WalletId, CurrencyId);
						SafeTrackPage("/A/BidPlaced");
						SafeTrackEvent("Bidding", "BidPlaced", "Auction #" + b);
						if (f >= 0) {
							SafeTrackEvent("Bidding", "BidPlacedTimer", "TimeLeft_" + f)
						}
						var n = "SessionPlacedBids";
						var m = jQuery.cookie(n);
						m = (m ? parseInt(m) : 0) + 1;
						jQuery.cookie(n, m, {
							path : "/"
						});
						if (k >= 2) {
							if (m == 3) {
								setTimeout(function () {
									alertMakeAutoBid("#AutoBidPopUp")
								}, 3000)
							}
						} else {
							setTimeout(function () {
								alertGetChipsEmpty("#WalletNowEmptyPopUp")
							}, 3000)
						}
					} else {
						g.removeClass(h);
						g.removeClass(d);
						j.text(a);
						alertBidNotTaken("#BidNotTaken", (l && l.d) ? l.d.Status : null);
						SafeTrackEvent("Bidding", "BidNotPlaced", (l && l.d) ? l.d.Status : "NETWORK")
					}
				}
			})
		} else {
			alertGetChipsEmpty("#WalletNotEnoughPopUp");
			SafeTrackEvent("Bidding", "BidNotPlaced", "WALLET_SOFT")
		}
	} else {
		document.location.href = "/Y/LogIn/"
	}
}
function alertBidNotTaken(a, b) {
	var d = jQuery(a);
	d.find(".reason").hide();
	if (!b) {
		b = "NETWORK"
	}
	d.find(".reason" + b).show();
	var c = {};
	c[d.find(".buttonCancel").text()] = function () {
		d.dialog("close")
	};
	showDialog(d, {
		modal : true,
		buttons : c
	})
}
function alertGetChipsEmpty(a) {
	var b = jQuery(a).find(".buttonAction");
	alertActionCancel(a, b.text(), b.attr("href"))
}
function alertMakeAutoBid(a) {
	var b = jQuery(a).find(".buttonAction");
	alertActionCancel(a, b.text(), b.attr("href"))
}
function alertActionCancel(a, c, b) {
	var d = {};
	if (c && b) {
		d[c] = function () {
			document.location.href = b
		}
	}
	var e = jQuery(a);
	d[e.find(".buttonCancel").text()] = function () {
		e.dialog("close")
	};
	showDialog(e, {
		modal : true,
		buttons : d
	})
}
var timeOutDate;
function actionDone() {
	var a = new Date();
	a.setTime(a.getTime() + 1000 * 60 * 30);
	timeOutDate = a
}
var noTimeout = 0;
function hasTimedout() {
	try {
		if (window.location.hash == "#NoTimeout" || window.location.hash == "#NoXMPP") {
			jQuery.cookie("NoTimeout", 1, {
				path : "/"
			});
			noTimeout = 1
		}
		if (noTimeout == 0) {
			noTimeout = -1;
			if (jQuery.cookie("NoTimeout") == "1") {
				noTimeout = 1
			}
		}
	} catch (a) {
		debug("hasTimedout exception: " + a)
	}
	return noTimeout != 1 && timeOutDate && timeOutDate < new Date()
}
var pageAuctionId = 0;
var startGetAuctions = false;
var startGetBids = false;
var startGetBestBids = false;
var startGetBidsCounts = false;
var lastUpdateId = 0;
var prizesAreExclusive = false;
var roundTripDelay = -1;
var isUnLoading = false;
function doStartPush() {
	return startGetAuctions || startGetBids || startGetBestBids || startGetBidsCounts
}
function getEverything() {
	if (lastUpdateId > 0 && XMPPServer && XMPPPushUser && xmppPush) {
		setTimeout("getEverything()", 5000);
		return
	} else {
		if (!doStartPush()) {
			return
		}
	}
	var a = new Date().getTime();
	jQuery.ajax({
		url : "/WebServices/BiddingWebService.asmx/GetBiddingEverything",
		data : '{ "req": {"SessionKey":"' + IdentificationId + '","AuctionId":"' + pageAuctionId + '","GetAuctions":"' + startGetAuctions + '","GetBids":"' + startGetBids + '","GetBestBids":"' + startGetBestBids + '","GetBestBidders":"' + startGetBidsCounts + '","SinceUpdateId":"' + lastUpdateId + '","BidCurrencyId":"' + PaidCurrencyId + '","WalletCurrencyId":"' + CurrencyId + '","Locale":"' + Locale + '" } }',
		success : function (b) {
			setSuccess();
			if (roundTripDelay < 0) {
				var e = new Date().getTime();
				roundTripDelay = Math.ceil((e - a) / 1000)
			}
			var c = 1;
			if (b && b.d) {
				lastUpdateId = b.d.LastUpdateId;
				handleAjaxResp(b);
				pushAuctions(b.d.Auctions, b.d.ServerTime);
				applyBids(b.d.Bids);
				applyBestBids(b.d.BestBids, b.d.ServerTime, true);
				applyBidsCounts(pageAuctionId, b.d.BidsCounts);
				hideMultiPrizes()
			} else {
				c = 10000
			}
			if (hasTimedout()) {
				var d = {};
				var f = jQuery("#TimeoutPopUp");
				d[f.find(".buttonCancel").text()] = function () {
					f.dialog("close")
				};
				showDialog(f, {
					modal : true,
					buttons : d,
					close : function (g, h) {
						actionDone();
						setTimeout("getEverything()", 1);
						jQuery(this).dialog("destroy")
					}
				})
			} else {
				setTimeout("getEverything()", c)
			}
		},
		error : function (b, d, c) {
			setError();
			debug("AJAX Network error: please check your connection.\r\nHere is the returned error: " + d + " " + c);
			setTimeout("getEverything()", 3000)
		}
	})
}
function getAuction(a) {
	jQuery.ajax({
		url : "/WebServices/BiddingWebService.asmx/GetAuction",
		data : '{ "req": {"SessionKey":"' + IdentificationId + '","AuctionId": "' + a + '","Locale":"' + Locale + '"} }',
		success : function (b) {
			if (b && b.d) {
				handleAjaxResp(b);
				updateAuction(b.d.Auction, true, b.d.ServerTime);
				applyBestBids(null, b.d.ServerTime, false)
			}
		}
	})
}
var oldAuctions = new Array();
var terminatedAuctions = new Array();
function pushAuctions(c, b) {
	if (c && c.length > 0) {
		for (var a = 0; a < c.length; a++) {
			savePushedAuction(c[a])
		}
		applyAuctions(null, b);
		applyBestBids(null, b, false)
	}
}
function pushAuction(b, a) {
	if (b) {
		savePushedAuction(b);
		applyAuctions(null, a);
		applyBestBids(null, a, false)
	}
}
function savePushedAuction(d) {
	if (d) {
		var a = false;
		for (var b = 0; b < oldAuctions.length; b++) {
			var c = oldAuctions[b];
			if (c && c.Id == d.Id) {
				oldAuctions[b] = d;
				a = true;
				break
			}
		}
		if (!a) {
			oldAuctions.push(d)
		}
	}
}
function isAuctionTerminatedRecently(b, a) {
	if (b.DateLastBidServerTime) {
		return (a - b.DateLastBidServerTime) < displayTerminatedAuctionsWithInplayDuring
	}
	return false
}
function isAuctionImminent(b, a) {
	return b.Status == "PENDING" && b.DateStartServerTime - a <= 60 * 60 * 24
}
function applyAuctions(g, d) {
	if (g) {
		oldAuctions = g
	} else {
		g = oldAuctions
	}
	if (g) {
		var f = function (k) {
			k.BlockType = "UNKNOWN";
			if (k == null) {
				return 0
			}
			var i = -1 / k.Id;
			if (k.Status == "CANCELED" || ((k.Status == "TERMINATED" || k.Status == "PAID" || k.Status == "REFUNDED") && !isAuctionTerminatedRecently(k, d))) {
				k.BlockType = "TERMINATED";
				return 10000000000 + (k.DateLastBid ? k.DateLastBid.getTime() : 0) + i
			}
			if (k.Status == "INPLAY" || k.Status == "SUSPENDED" || k.Status == "TERMINATED" || k.Status == "PAID" || k.Status == "REFUNDED" || isAuctionImminent(k, d)) {
				k.BlockType = "INPLAY";
				return 10000000000000 + k.AuctionCost + i
			}
			if (k.Status == "PENDING") {
				k.BlockType = "PENDING";
				return 10000000 + k.AuctionCost + i
			}
			return 0
		};
		var b = function (k, i) {
			return f(i) - f(k)
		};
		g.sort(b);
		var j = false;
		for (var e = 0; e < g.length; e++) {
			var a = g[e];
			if (a.BlockType == "TERMINATED") {
				terminatedAuctions[a.Id] = a
			} else {
				var c = !j && a.CanBeStar && (a.Status == "INPLAY" || a.Status == "SUSPENDED");
				j = j || c;
				updateAuction(a, c, d)
			}
		}
		var h = terminatedAuctions.slice(0);
		h.sort(b);
		jQuery("#TerminatedAuctionBlock").empty();
		for (var e = 0; e < h.length && e < 4; e++) {
			var a = h[e];
			updateAuction(a, false, d)
		}
	}
}
var auctionsDetails = new Array();
var displayTerminatedAuctionsWithInplayDuring = 1800;
function updateAuction(a, e, d) {
	if (a && (!pageAuctionId || pageAuctionId == a.Id)) {
		auctionsDetails[a.Id] = a;
		if (a.BidCurrencyId == PaidCurrencyId && a.WalletCurrencyId == CurrencyId && (pageAuctionId == 0 || a.Id == pageAuctionId)) {
			var c = isAuctionImminent(a, d);
			if (a.DealAuction) {
				setAuctionImminentTimer(a.Id, a.DateLastBidServerTime, d)
			} else {
				if (c) {
					setAuctionImminentTimer(a.Id, a.DateStartServerTime, d)
				}
			}
			var g = pageAuctionId > 0 ? "#BigAuctionBlock" : "#AuctionBlock";
			var b = g;
			if (e) {
				b = "#BigAuctionBlock"
			} else {
				if (a.Status == "PENDING" && !c) {
					b = "#PendingAuctionBlock"
				} else {
					if (a.Status == "TERMINATED" || a.Status == "PAID" || a.Status == "CANCELED" || a.Status == "REFUNDED") {
						if (isAuctionTerminatedRecently(a, d)) {}
						else {
							b = "#TerminatedAuctionBlock"
						}
					}
				}
			}
			var k = jQuery(b);
			if (b != g && k.size() <= 0) {
				b = g;
				k = jQuery(b)
			}
			var j = jQuery("#Auction_" + a.Id);
			var h = false;
			var i = function (m) {
				if (m) {
					if (a.DealAuction) {
						if (!m.hasClass("Auction_DEALAUCTION")) {
							m.addClass("Auction_DEALAUCTION")
						}
						m.find(".CurrentPrice").text(a.AuctionCost);
						if (a.QuantityTotal > 0) {
							var l = Math.max(Math.min(Math.floor(a.QuantityLeft / a.QuantityTotal * 100), 100), 0);
							m.find("#AuctionProgressBar_" + a.Id).progressbar().progressbar("option", "value", l);
							m.find("#AuctionProgressBarText_" + a.Id).find(".CurrentStockPercent").text(l)
						} else {
							m.find(".ProgressBar,.ProgressBarText").hide()
						}
					}
				}
			};
			if (j.size() > 0 && k.find("#" + j.get(0).id).size() > 0) {
				if (!j.hasClass("Auction_status_" + a.Status)) {
					var f = jQuery(getTemplateParsed(a, d, b, g));
					i(f);
					j.after(f);
					j.remove();
					h = true
				} else {
					i(j)
				}
			} else {
				if (k.size() > 0 && (pageAuctionId || a.Status == "INPLAY" || a.Status == "PENDING" || a.Status == "SUSPENDED" || a.Status == "TERMINATED" || a.Status == "PAID" || a.Status == "CANCELED" || a.Status == "REFUNDED")) {
					j.remove();
					var f = jQuery(getTemplateParsed(a, d, b, g));
					i(f);
					k.append(f);
					h = true
				}
			}
			if (c) {
				j.addClass("Auction_status_IMMINENT")
			} else {
				if (j.hasClass("Auction_status_IMMINENT")) {
					j.removeClass("Auction_status_IMMINENT")
				}
			}
			if (h) {
				jQuery("#AuctionProgressBar_" + a.Id).progressbar()
			}
		} else {
			jQuery("#Auction_" + a.Id).remove()
		}
		if (a.Status == "INPLAY") {
			auctionsBidsDuration[a.Id] = a.BidTime
		}
	}
}
function getTemplateParsed(e, c, b, d) {
	var a = jQuery(b + "Template");
	if (b != d && a.size() <= 0) {
		a = jQuery(d + "Template")
	}
	return a.parseTemplate({
		auction : e,
		serverTime : c
	})
}
function applyBids(g) {
	if (g && g.length > 0) {
		var c = g[0];
		var b = jQuery(".Auction_" + c.AuctionId);
		var a = parseFloat(b.find("#ReservePrice").val());
		if (!isNaN(a) && a > 0 && a > c.BidPrice) {
			if (!b.hasClass("RESERVE")) {
				b.addClass("RESERVE")
			}
		} else {
			b.removeClass("RESERVE")
		}
		for (var f = 0; f < g.length; f++) {
			var h = f + 1;
			var e = g[f];
			var d = b.find(".TimeRank.Rank" + h);
			d.find(".PublicName").text(e.PublicName);
			d.find(".UserId").text(e.UserId);
			d.find(".Price").text(formatNumber(e.BidPrice, 2));
			d.removeClass("Nobody").parents(".Nobody").removeClass("Nobody")
		}
	}
}
var oldBids = new Array();
function pushBid(a, d) {
	if (a) {
		var c = false;
		var f = false;
		for (var b = 0; b < oldBids.length; b++) {
			var e = oldBids[b];
			if (e && e.AuctionId == a.AuctionId) {
				if (e.BidId < a.BidId) {
					oldBids[b] = a;
					f = true
				}
				c = true;
				break
			}
		}
		if (!c) {
			oldBids.push(a);
			f = true
		}
		updateBid(a, d, f)
	}
}
var bestBids = new Array();
function applyBestBids(f, e, b) {
	if (f) {
		for (var d = 0; d < f.length; d++) {
			var a = f[d];
			if (!bestBids[a.AuctionId] || (a && bestBids[a.AuctionId].BidId < a.BidId)) {
				bestBids[a.AuctionId] = a
			}
		}
	}
	for (var c in bestBids) {
		updateBid(bestBids[c], e, b)
	}
	launchUpdateBidTimers();
	jQuery(".Auction").removeClass("Auction_status_LOADING")
}
var bidServerTimes = new Array();
var auctionBlinks = new Array();
function updateBid(c, d, b) {
	if (c != null) {
		var g = jQuery("#Auction_" + c.AuctionId);
		g.removeClass("Auction_status_WAITING_SERVER");
		g.removeClass("Auction_status_NOBIDDER");
		g.find(".CurrentPrice").text(formatNumber(c.BidPrice, 2));
		g.find(".CurrentWinnerPublicName").text(c.PublicName);
		if (UserId > 0 && c.UserId == UserId) {
			g.addClass("Auction_status_HOLD")
		} else {
			g.removeClass("Auction_status_HOLD")
		}
		if (b) {
			setAuctionTimer(c.AuctionId, c.BidServerTime, d)
		}
		if (auctionBlinks[c.AuctionId] && auctionBlinks[c.AuctionId] < c.BidId) {
			var a = g.find(".Timer");
			try {
				a.effect("highlight", {
					color : "#cd0a0a"
				}, 1500)
			} catch (e) {
				debug("updateBid effect highlight error: " + e)
			}
		}
		auctionBlinks[c.AuctionId] = Math.max(c.BidId, (auctionBlinks[c.AuctionId] && !isNaN(auctionBlinks[c.AuctionId])) ? auctionBlinks[c.AuctionId] : 0);
		var g = auctionsDetails[c.AuctionId];
		if (g) {
			var f = g.AuctionCost - c.BidPrice;
			jQuery("#Savings_" + g.Id).text(formatNumber(f, 2));
			jQuery("#SavingsPercent_" + g.Id).text(formatNumber(f / g.AuctionCost * 100, 2))
		}
	}
}
function applyBidsCounts(b, a) {
	if (b > 0 && a) {
		for (var d = 0; d < a.length; d++) {
			var f = d + 1;
			var e = a[d];
			var c = jQuery(".Auction_" + b + " .BidsCountRank.Rank" + f);
			c.find(".PublicName").text(e.PublicName);
			c.find(".UserId").text(e.UserId);
			c.find(".BidsCount").text(formatNumber(e.Count));
			c.removeClass("Nobody").parents(".Nobody").removeClass("Nobody")
		}
	}
}
var setErrorDate = null;
var setErrorInterval = null;
function setError() {
	if (isUnLoading) {
		setSuccess()
	}
	if (setErrorDate) {
		return
	}
	setErrorDate = new Date();
	setTimeout(function () {
		if (!isUnLoading && setErrorDate) {
			var a = jQuery("#ServerConnectionLost");
			var b = function () {
				var c = Math.ceil((new Date().getTime() - setErrorDate.getTime() + 1) / 1000);
				setTimerValue(a, a.find(".Timer"), null, c, 1)
			};
			setErrorInterval = setInterval(b, 1000);
			b();
			a.slideDown()
		}
	}, 2000)
}
function setSuccess() {
	setErrorDate = null;
	if (setErrorInterval) {
		clearInterval(setErrorInterval)
	}
	jQuery("#ServerConnectionLost").slideUp()
}
function hideMultiPrizes() {
	if (prizesAreExclusive) {
		var a = jQuery("#winners");
		if (a.size() > 0) {
			a.find(".Prize").css("visibility", "visible");
			a.find(".Rank:not(.HavePrize)").find(".Prize").html("&nbsp;");
			hideMultiPrizesDuplicates(null, a, ".TimeRank", ".BidsCountRank", 1, new Array())
		}
	}
}
function hideMultiPrizesDuplicates(d, k, c, b, i, f) {
	if (c) {
		if (!d) {
			d = ","
		}
		var a = k.find(c + ".Rank" + i);
		if (a.size() > 0) {
			var h = parseInt(a.find(".UserId").text());
			if (h > 0) {
				var e = a.hasClass("HavePrize");
				var g = a.find(".Prize");
				var j = a.find(".OriginalPrize");
				if (d.match("," + h + ",")) {
					if (e) {
						g.css("visibility", "hidden");
						f.push(j.html())
					}
				} else {
					if (f.length > 0) {
						if (e) {
							f.push(j.html())
						}
						g.html(f.shift());
						d += h + ","
					} else {
						if (e) {
							d += h + ","
						}
						g.html(j.html())
					}
				}
			}
			f = hideMultiPrizesDuplicates(d, k, c, null, i + 1, f);
			if (b) {
				f = hideMultiPrizesDuplicates(d, k, b, null, 1, f)
			}
		}
	}
	return f
}
var auctionsBidsDuration = new Array();
var auctionsTimers = new Array();
var auctionsImminentTimers = new Array();
var auctionsImminentDateStart = new Array();
var loadServerTime = 0;
var lastServerTime = 0;
var updateBidTimersInterval;
function setAuctionTimer(a, c, d) {
	if (loadServerTime <= 0) {
		loadServerTime = d
	}
	lastServerTime = Math.max(lastServerTime, d);
	var e = Math.max(c, (bidServerTimes[a] && !isNaN(bidServerTimes[a])) ? bidServerTimes[a] : 0);
	bidServerTimes[a] = e;
	var b = new Date();
	auctionsTimers[a] = b.getTime() - (lastServerTime - e) * 1000;
	auctionsImminentTimers[a] = null;
	updateBidTimer(a, b)
}
function setAuctionImminentTimer(a, b, c) {
	lastServerTime = Math.max(lastServerTime, c);
	auctionsImminentTimers[a] = b - c;
	auctionsImminentDateStart[a] = b
}
function launchUpdateBidTimers() {
	if (updateBidTimersInterval) {
		clearInterval(updateBidTimersInterval)
	}
	updateBidTimersInterval = setInterval("updateBidTimers()", 1000);
	updateBidTimers()
}
function updateBidTimers() {
	var b = new Date();
	for (var a in auctionsBidsDuration) {
		updateBidTimer(a, b)
	}
	for (var a in auctionsImminentTimers) {
		updateImminentTimer(a, b)
	}
}
function updateBidTimer(c, b) {
	c = parseInt(c);
	if (c > 0) {
		var d = getTimeLeftObject(c, b);
		if (d != null) {
			var f = d.timeLeft;
			var a = d.bidDuration;
			var e = jQuery("#Auction_" + c);
			if (f >= 0) {
				setTimerValue(e, e.find(".Timer"), jQuery("#AuctionProgressBar_" + c), f, a)
			}
		}
	}
}
function updateImminentTimer(b, a) {
	b = parseInt(b);
	if (b > 0) {
		var d = --auctionsImminentTimers[b];
		var c = jQuery("#Auction_" + b);
		if (c.hasClass("Auction_status_IMMINENT") || c.hasClass("Auction_DEALAUCTION")) {
			setTimerValue(c, c.find(".Timer"), null, d, 1)
		}
	}
}
function setTimerValue(f, h, g, d, a) {
	d = Math.max(d, 0);
	var c = d;
	var k = Math.floor(c / (24 * 60 * 60));
	c -= k * 24 * 60 * 60;
	h.find(".TimerDay").text(k);
	if (k > 0) {
		h.addClass("Delay_DAY")
	} else {
		h.removeClass("Delay_DAY")
	}
	var i = Math.floor(c / (60 * 60));
	c -= i * 60 * 60;
	h.find(".TimerHour").text(i);
	if (i > 0) {
		h.addClass("Delay_HOUR")
	} else {
		h.removeClass("Delay_HOUR")
	}
	var b = Math.floor(c / 60);
	c -= b * 60;
	h.find(".TimerMin").text((k > 0 || i > 0) ? padLeft(b, 2, "0") : b);
	var j = c;
	h.find(".TimerSec").text(padLeft(j, 2, "0"));
	if (d <= 10) {
		f.addClass("LowTime")
	} else {
		f.removeClass("LowTime")
	}
	if (d <= 2) {
		f.addClass("SuperLowTime")
	} else {
		f.removeClass("SuperLowTime")
	}
	if (g != null) {
		var e = Math.min(Math.max(100 - d / Math.max(a, 1) * 100, 0), 100);
		if (!isNaN(e)) {
			g.progressbar("option", "value", e)
		}
	}
	if (d <= 0) {
		f.addClass("Auction_status_CHECKING")
	} else {
		f.removeClass("Auction_status_CHECKING")
	}
}
function getTimeLeftObject(c, b) {
	var d = auctionsTimers[c];
	if (d) {
		var f = Math.round(((b ? b : (new Date())).getTime() - d) / 1000) + Math.max(roundTripDelay, 1);
		var a = auctionsBidsDuration[c] - TimerMargin;
		if (a > 0) {
			var e = a - f;
			return {
				timeLeft : Math.min(Math.max(e, 0), a),
				bidDuration : a
			}
		}
	}
	return null
}
var auctionsDisappearTimeouts = new Array();
function appearAuctionOptions(a) {
	clearDisappearTimeout(a);
	jQuery("#Auction_Options_" + a).animate({
		marginTop : "0"
	}, 250)
}
function disappearAuctionOptions(a) {
	if (!auctionsDisappearTimeouts[a]) {
		auctionsDisappearTimeouts[a] = setTimeout(function () {
				jQuery("#Auction_Options_" + a).animate({
					marginTop : "-17px"
				}, 250)
			}, 50)
	}
}
function clearDisappearTimeout(a) {
	if (auctionsDisappearTimeouts[a]) {
		clearTimeout(auctionsDisappearTimeouts[a]);
		auctionsDisappearTimeouts[a] = null
	}
}
jQuery(document).ready(function () {
	actionDone();
	jQuery("table.alternable tbody tr:even,tr.alternable:even,ul.alternable li:even").addClass("alt");
	jQuery("#header").find(".inputText:not(.inputWithContainer),.inputButton:not(.inputWithContainer),.inputSubmit:not(.inputWithContainer),select:not(.inputWithContainer)").addClass("inputWithContainer").wrap('<div class="inputContainer"></div>');
	jQuery("textarea:not(.html):not(.replyBox):not(.noAutoGrow)").addClass("noAutoGrow").autogrow({});
	jQuery("input[type='checkbox']").each(function () {
		var a = jQuery(this);
		var b = a.closest(".fakeInputCheckbox");
		if (b.size() > 0) {
			a.addClass("displayNone");
			this.checked ? b.addClass("fakeInputCheckboxOn") : b.removeClass("fakeInputCheckboxOn")
		}
	});
	jQuery(".fakeInputCheckbox").click(function () {
		var b = jQuery(this);
		var a = b.find("input[type='checkbox']").get(0);
		b.hasClass("fakeInputCheckboxOn") ? b.removeClass("fakeInputCheckboxOn") : b.addClass("fakeInputCheckboxOn");
		if (b.hasClass("fakeInputCheckboxOn")) {
			a.checked = true
		} else {
			a.checked = false
		}
		return false
	});
	setTimeout("SafeTrackEvent('unbounce','unbounce','unbounce',60)", 60000);
	jQuery.ajaxSetup({
		async : true,
		contentType : "application/json; charset=utf-8",
		dataType : "text",
		timeout : 62 * 2 * 1000,
		type : "POST",
		dataFilter : function (b, a) {
			return parseJSON(correctAspNetJSON(b))
		},
		error : function (a, c, b) {
			debug("AJAX Network error: please check your connection.\r\nHere is the returned error: " + c + " " + b)
		}
	});
	jQuery(window).unload(function () {
		isUnLoading = true
	});
	setTimeout("startPush()", 1000);
	document.onclick = function (a) {
		actionDone()
	}
});
window.onload = startPush;
var pushStarted = false;
var xmppPush = false;
var xmppDontReconnect = false;
var xmppPushServerIndex = -1;
var xmppConnection;
function startPush() {
	if (!pushStarted) {
		pushStarted = true;
		if (pageAuctionId > 0) {
			setTimeout("getAuction(" + pageAuctionId + ");", 1)
		}
		setTimeout("getEverything();", 1);
		setInterval("lastServerTime++;", 1000);
		startXMPPPush()
	}
}
function startXMPPPush() {
	if (xmppDontReconnect) {
		return
	}
	var c = jQuery("#PushStatus");
	if (XMPPServer && XMPPPushUser && doStartPush() && window.location.hash != "#NoXMPP") {
		var b = XMPPConnectServers.split(",");
		if (xmppPushServerIndex < 0) {
			xmppPushServerIndex = Math.round(Math.random() * 1000)
		} else {
			xmppPushServerIndex++
		}
		xmppPushServerIndex = xmppPushServerIndex % b.length;
		var d = b[xmppPushServerIndex];
		c.attr("title", "Push server #" + d);
		xmppConnection = new Strophe.Connection("/http-bind/xmpp/" + d);
		var a = function (g, e) {
			var f = new RegExp("^.*<" + e + ">(.*)</" + e + ">.*$", "g");
			return g.replace(f, "$1")
		};
		xmppConnection.addHandler(function (j) {
			var i = jQuery(j).text();
			var h = a(i, "jsonObject");
			if (h) {
				h = correctAspNetJSON(h.trim());
				if (h.startsWith("{") || h.startsWith("[")) {
					var g = a(i, "serverTime");
					var f = a(i, "objectType");
					var e = parseJSON(h);
					if (f.indexOf("BidCount") >= 0 && f.indexOf("[]") >= 0) {
						applyBidsCounts(pageAuctionId, e)
					} else {
						if (f.indexOf("Auction") >= 0) {
							pushAuction(e, g)
						} else {
							if (f.indexOf("Bid") >= 0) {
								pushBid(e, g)
							}
						}
					}
				}
			}
			return true
		}, null, "message", "headline", null, null, null);
		xmppConnection.connect(XMPPServer, null, function (e) {
			c.removeClass("PushConnecting").removeClass("PushDisconnected").removeClass("PushConnected");
			if (e == Strophe.Status.CONNECTING || e == Strophe.Status.AUTHENTICATING) {
				c.addClass("PushConnecting");
				xmppPush = false
			} else {
				if (e == Strophe.Status.CONNECTED || e == Strophe.Status.ATTACHED) {
					if (e == Strophe.Status.CONNECTED) {
						if (startGetAuctions) {
							xmppConnection.pubsub.subscribe(xmppConnection.jid, "pubsub." + XMPPServer, "/home/" + XMPPServer + "/" + XMPPPushUser + "/JSON/Bidding/Auctions/" + Locale, null, function () {}, function () {})
						}
						if (startGetBids || startGetBestBids) {
							xmppConnection.pubsub.subscribe(xmppConnection.jid, "pubsub." + XMPPServer, "/home/" + XMPPServer + "/" + XMPPPushUser + "/JSON/Bidding/Bids", null, function () {}, function () {})
						}
						if (startGetBidsCounts) {
							xmppConnection.pubsub.subscribe(xmppConnection.jid, "pubsub." + XMPPServer, "/home/" + XMPPServer + "/" + XMPPPushUser + "/JSON/Bidding/BidsCounts/AuctionId_" + pageAuctionId, null, null, null)
						}
						var f = function () {
							xmppDontReconnect = true;
							xmppConnection.disconnect()
						};
						window.onunload = f;
						jQuery(window).bind("unload", f);
						xmppPush = true
					}
					c.addClass("PushConnected")
				} else {
					setTimeout("startXMPPPush()", 2000);
					c.addClass("PushDisconnected");
					xmppPush = false
				}
			}
		});
		setTimeout(function () {
			if (!xmppPush) {
				xmppConnection.disconnect()
			}
		}, 10000)
	} else {
		c.hide()
	}
};
